def __init__(self, matcher):
self.matcher = matcher
- def is_noalert(self, rule):
- for option in rule.options:
- if option["name"] == "flowbits" and option["value"] == "noalert":
- return True
- return False
-
def match(self, rule):
- if self.is_noalert(rule):
+ if rule["noalert"]:
return False
return self.matcher.match(rule)
- **references**: References as a list
- **classtype**: The classification type
- **priority**: The rule priority, 0 if not provided
+ - **noalert**: Is the rule a noalert rule
- **raw**: The raw rule as read from the file or buffer
:param enabled: Optional parameter to set the enabled state of the rule
self["references"] = []
self["classtype"] = None
self["priority"] = 0
+ self["noalert"] = False
self["options"] = []
rule[name] += [v.strip() for v in val.split(",")]
elif name == "flowbits":
rule.flowbits.append(val)
+ if val.find("noalert") > -1:
+ rule["noalert"] = True
elif name == "reference":
rule.references.append(val)
elif name == "msg":
rule = suricata.update.rule.parse(rule_string)
self.assertEqual("", rule["msg"])
+ def test_noalert(self):
+ rule_string = u"""alert ip any any -> any any (content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:10000000; rev:1;)"""
+ rule = suricata.update.rule.parse(rule_string)
+ self.assertFalse(rule["noalert"])
+
+ rule_string = u"""alert ip any any -> any any (content:"uid=0|28|root|29|"; classtype:bad-unknown; flowbits:noalert; sid:10000000; rev:1;)"""
+ rule = suricata.update.rule.parse(rule_string)
+ self.assertTrue(rule["noalert"])
+
def test_add_option(self):
rule_string = u"""alert ip any any -> any any (content:"uid=0|28|root|29|"; classtype:bad-unknown; sid:10000000; rev:1;)"""
rule = suricata.update.rule.parse(rule_string, "local.rules")