From 352dc8e843491ce29e3dd9396477cb67fa2ca4f3 Mon Sep 17 00:00:00 2001 From: Shaheed Haque Date: Sun, 29 Jan 2017 20:58:37 +0000 Subject: Bindings: Add an end marker to the regex pattern Fix the anchoring of the regular expression matching to cover the complete input. This was an oversight and should have no visible effects except that if new fields are added to a rule database, existing rules with wildcards will greedily match the new fields. --- find-modules/rules_engine.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'find-modules/rules_engine.py') diff --git a/find-modules/rules_engine.py b/find-modules/rules_engine.py index 9c617159..8ec5ac5c 100755 --- a/find-modules/rules_engine.py +++ b/find-modules/rules_engine.py @@ -80,7 +80,10 @@ class Rule(object): try: groups = ["(?P<{}>{})".format(name, pattern) for pattern, name in pattern_zip] groups = _SEPARATOR.join(groups) - self.matcher = re.compile(groups) + # + # We'll use re.match to anchor the start of the match, and so need a $ to anchor the end. + # + self.matcher = re.compile(groups + "$") except Exception as e: groups = ["{} '{}'".format(name, pattern) for pattern, name in pattern_zip] groups = ", ".join(groups) -- cgit v1.2.1