Exemple #1
0
 def validate_rules(self):
     """Validate Rules before scanning."""
     for rule in self.scan_rules:
         if not isinstance(rule, dict):
             raise exceptions.InvalidRuleFormatException(
                 'Pattern Matcher Rule format is invalid.')
         if not rule.get('type'):
             raise exceptions.TypeKeyMissingError(
                 'The rule is missing the key \'type\'')
         if not rule.get('pattern'):
             raise exceptions.PatternKeyMissingError(
                 'The rule is missing the key \'pattern\'')
         all_mts = [m for m in dir(matchers) if m.startswith('R')]
         pattern_name = rule['type']
         if pattern_name not in all_mts:
             supported = ', '.join(all_mts)
             raise exceptions.MatcherNotFoundException(
                 f'Matcher \'{pattern_name}\' is not supported.'
                 f' Available matchers are {supported}', )
Exemple #2
0
 def validate_rules(self):
     """Validate Rules before scanning."""
     for rule in self.scan_rules:
         if not isinstance(rule, dict):
             raise exceptions.InvalidRuleFormatError(
                 'Choice Matcher Rule format is invalid.')
         if not rule.get('id'):
             raise exceptions.TypeKeyMissingError(
                 'The rule is missing the key \'id\'')
         if not rule.get('type'):
             raise exceptions.PatternKeyMissingError(
                 'The rule is missing the key \'type\'')
         if not rule.get('choice_type'):
             raise exceptions.PatternKeyMissingError(
                 'The rule is missing the key \'choice_type\'')
         if not rule.get('selection'):
             raise exceptions.PatternKeyMissingError(
                 'The rule is missing the key \'selection\'')
         if not rule.get('choice'):
             raise exceptions.PatternKeyMissingError(
                 'The rule is missing the key \'choice\'')