Open andrewbolster opened 6 years ago
I dont get the use case in which this could be misleading or considered as a bug.
Could you please explain this?
In the example above the signature has multiple content fields;
{'name': 'content', 'value': '"|55 04 03|"'},
{'name': 'content', 'value': '"|0f|directory92.com"'},
But the parsed rule object only presents the last one;
{'content':'"|0f|directory92.com"'},
IMO its some kind of unwanted bug caused by this line of code:
# omissis
else:
rule[name] = val
# omissis
If you better inspect the parsed rule you can also note these other values which do not make sense in that place:
'distance': '1',
'within': '16',
'tag': 'session,5,packets'
If you need to check for content
options its better to inspect the options
key.
A fix can be done easily by removing that line of code.
Maybe @jasonish this could be pointed out also in suricata-update
.
Yes, the fix will be to remove the field from the decode rules and loop through the options.
This stuff has been removed from suricata-update already as its not relevant to that app.
As per snort docs:
Example ET Rule with multiple contents:
rule.parse
output (with highlighting)While the correct
content
data is extractable from theoptions
object, this may be misleading, particularly in bulk-rule-processing (as I was doing).Suggested fixes
Either:
Make
content
a list to reflect the specification and add a specificelif name = 'content'
options->rule loop inparse
Or:
Prevent clobbering in the same loop by doing a generic
name
existence check and listifying+appending if thename
already exists in therule