Tests for rule name matching using patterns

Modify the disabled_rules_using_regex test to
disabled_rules_using_substring with an appropriate substring.

Also add a test where rule names have regex chars and allow rule names
to have regex chars when parsing falco's output in tests. These changes
are future-looking in case we want to add back support for rule
enabling/disabling using regexes.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
This commit is contained in:
Mark Stemm
2019-07-29 12:20:54 -07:00
committed by Leo Di Donato
parent 3fedd00cfc
commit a42ec9d7c7
3 changed files with 37 additions and 3 deletions

View File

@@ -269,7 +269,7 @@ class FalcoTest(Test):
triggered_rules = match.group(1)
for rule, count in self.detect_counts.iteritems():
expected = '\s{}: (\d+)'.format(rule)
expected = '\s{}: (\d+)'.format(re.sub(r'([$\.*+?()[\]{}|^])', r'\\\1', rule))
match = re.search(expected, triggered_rules)
if match is None: