Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, config, default_rules_config, data):
self.config = config
self.path_rules = data.get('rules')
validate_rule_patterns(self.path_rules)
self.excluded_rules = data.get('excluded_rules', [])
validate_rule_patterns(self.excluded_rules)
self._rules_config = (data.get('rules_config', {}) or
default_rules_config)
# Filter checkers
patterns = self.path_rules if self.path_rules is not None else self.config.rules
excluded_patterns = self.excluded_rules
self.checkers = {
rule: klass for (rule, klass) in xiblint.rules.rule_checkers.items()
if any(fnmatch(rule, pattern) for pattern in patterns) and
not any(fnmatch(rule, pattern) for pattern in excluded_patterns)
}