]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
framework: adds feature filtering per check 419/head
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 8 Jan 2021 14:50:19 +0000 (15:50 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 23 Jan 2021 17:35:47 +0000 (18:35 +0100)
README.md
run.py
tests/http2-bugfixes/test.yaml

index 184d6bd9b309666a5d17e8a9589da93524b3e734..a68a289a51feac64b09e2079df65237afb353b79 100644 (file)
--- a/README.md
+++ b/README.md
@@ -101,6 +101,9 @@ checks:
   # A verification filter that is run over the eve.json. Multiple
   # filters may exist and all must pass for the test to pass.
   - filter:
+      # Additional feature needed to run this specific filter
+      feature: HTTP2_DECOMPRESSION
+
       # The number of records this filter should match.
       count: 1
          
diff --git a/run.py b/run.py
index 095be190d76123e0c15bb1a0f7f3c672ed5d8bb0..eb622719239f59741dac9a26ecd0266089939065 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -314,10 +314,11 @@ class StatsCheck:
 
 class FilterCheck:
 
-    def __init__(self, config, outdir, suri_version):
+    def __init__(self, config, outdir, suricata_config):
         self.config = config
         self.outdir = outdir
-        self.suri_version = suri_version
+        self.suricata_config = suricata_config
+        self.suri_version = suricata_config.version
 
     def run(self):
         req_version = self.config.get("version")
@@ -331,7 +332,11 @@ class FilterCheck:
                         "Suricata v{} not found".format(version))
         elif req_version and min_version:
             raise TestError("Specify either min-version or version")
-
+        feature = self.config.get("feature")
+        if feature != None:
+            if not self.suricata_config.has_feature(feature):
+                raise UnsatisfiedRequirementError(
+                                                  "Suricata feature {} not present".format(feature))
         if "filename" in self.config:
             json_filename = self.config["filename"]
         else:
@@ -633,7 +638,7 @@ class TestRunner:
     @handle_exceptions
     def perform_filter_checks(self, check, count, test_num):
         count = FilterCheck(check, self.output,
-                self.suricata_config.version).run()
+                self.suricata_config).run()
         return count
 
     @handle_exceptions
index 711a319428a94051465a93397b26e9b537216ae8..f868748a435dbe7530bca678d09ddf24d3f03f98 100644 (file)
@@ -16,12 +16,14 @@ checks:
         event_type: anomaly
 # check gzip decompresser
   - filter:
+      feature: HTTP2_DECOMPRESSION
       count: 1
       match:
         event_type: fileinfo
         fileinfo.size: 639
 # check brotli decompresser
   - filter:
+      feature: HTTP2_DECOMPRESSION
       count: 1
       match:
         event_type: fileinfo