]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
modify filters: better error on badly formatted filter
authorJason Ish <jason.ish@oisf.net>
Wed, 8 Apr 2020 17:38:17 +0000 (11:38 -0600)
committerJason Ish <jason.ish@oisf.net>
Wed, 8 Apr 2020 17:38:17 +0000 (11:38 -0600)
Instead of exiting with an uncaught exception on a badly formatted
modify filter, convert the exception to an ApplicationError that
will be logged, along with the line that is badly formatted.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/3536

suricata/update/main.py

index b926ae8b4c1713b7e17a2fd0d6a40d4e7fb15734..bbb95f1b742a70e1f939a2c5b123e71f87d981cf 100644 (file)
@@ -237,11 +237,12 @@ def load_filters(filename):
             line = line.rsplit(" #")[0]
 
             line = re.sub(r'\\\$', '$', line)  # needed to escape $ in pp
-            rule_filter = matchers_mod.ModifyRuleFilter.parse(line)
-            if rule_filter:
+            try:
+                rule_filter = matchers_mod.ModifyRuleFilter.parse(line)
                 filters.append(rule_filter)
-            else:
-                log.error("Failed to parse modify filter: %s" % (line))
+            except Exception as err:
+                raise exceptions.ApplicationError(
+                    "Failed to parse modify filter: {}".format(line))
 
     return filters