Skip to content

Commit

Permalink
modify filters: better error on badly formatted filter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jasonish committed Apr 8, 2020
1 parent 70cd353 commit da51abb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions suricata/update/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit da51abb

Please sign in to comment.