Ejemplo n.º 1
0
    def entry_is_not_ignored(self, path, entrytype, do_check):
        '''
        see if the given entry is in NOT in the ingored lists and return
        True if so, False otherwise
        we only do this check if the do_check argment is set to 'check';
        otherwise we default to True
        '''
        if do_check != 'check':
            return True

        basedir = self.get_basedir_from_path(path)
        if self.audit_type == 'logs' and entrytype == 'file':
            path = LocalLogsAuditor.normalize(path)

        if entrytype == 'file':
            checker = clouseau.retention.utils.ignores.file_is_ignored
            dirs = False
        else:
            checker = clouseau.retention.utils.ignores.dir_is_ignored
            dirs = True
            for ignored in [self.ignores.global_ignored, self.ignored_also]:
                if dirs:
                    result = checker(path, ignored)
                else:
                    result = checker(path, basedir, ignored)
                if result:
                    return False

            for ignored in [
                    self.ignores.perhost_ignored, self.ignored_from_rulestore
            ]:
                if self.cenv.host in ignored:
                    if dirs:
                        result = checker(path, ignored[self.cenv.host])
                    else:
                        result = checker(path, basedir,
                                         ignored[self.cenv.host])
                    if result:
                        return False

        return True
Ejemplo n.º 2
0
    def entry_is_not_ignored(self, path, entrytype, do_check):
        '''
        see if the given entry is in NOT in the ingored lists and return
        True if so, False otherwise
        we only do this check if the do_check argment is set to 'check';
        otherwise we default to True
        '''
        if do_check != 'check':
            return True

        basedir = self.get_basedir_from_path(path)
        if self.audit_type == 'logs' and entrytype == 'file':
            path = LocalLogsAuditor.normalize(path)

        if entrytype == 'file':
            checker = clouseau.retention.utils.ignores.file_is_ignored
            dirs = False
        else:
            checker = clouseau.retention.utils.ignores.dir_is_ignored
            dirs = True
            for ignored in [self.ignores.global_ignored,
                            self.ignored_also]:
                if dirs:
                    result = checker(path, ignored)
                else:
                    result = checker(path, basedir, ignored)
                if result:
                    return False

            for ignored in [self.ignores.perhost_ignored,
                            self.ignored_from_rulestore]:
                if self.cenv.host in ignored:
                    if dirs:
                        result = checker(path, ignored[self.cenv.host])
                    else:
                        result = checker(path, basedir, ignored[self.cenv.host])
                    if result:
                        return False

        return True