import yaml
import glob
import re
+import json
from collections import namedtuple
import yaml
return False
return True
-
+
class SuricataConfig:
def __init__(self, version):
print("FAIL: process returned with non-0 exit code: %d" % r)
return False
- return self.check()
+ return self.check(test_config)
+
+ def check(self, test_config):
+
+ if "checks" in test_config.config:
+ for check in test_config.config["checks"]:
+ for key in check:
+ if key == "signature-id":
+ if not self.check_signature_id(check[key]):
+ raise Exception("signature-id %d not found" % (
+ check[key]))
- def check(self):
if not os.path.exists(os.path.join(self.directory, "check.sh")):
print("OK")
return True
print("OK")
return True
+ def check_signature_id(self, sig_id):
+ with open(
+ os.path.join(
+ self.directory, "output", "eve.json"), "rb") as fileobj:
+ for line in fileobj:
+ event = json.loads(line)
+ if "alert" in event:
+ if event["alert"]["signature_id"] == sig_id:
+ return True
+ return False
+
def default_args(self):
args = [
os.path.join(self.cwd, "src/suricata"),