]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: don't fail if the pcap filename is falsey
authorJason Ish <jason.ish@oisf.net>
Thu, 4 Aug 2022 16:20:14 +0000 (10:20 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 13 Sep 2022 10:19:07 +0000 (12:19 +0200)
Instead, if the pcap filename is a "falsey" value in Python, treat it
like "pcap: false" in the requires section as this is an easy mistake to
make, and in some cases makes more sense to allow false where you could
also override the filename.

README.md
run.py

index e038603334def12882e4b8b4d9536a515ee3810a..cc4f390c4b5a26ad611af99c8d21ecaa7e6dd7e7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -96,6 +96,10 @@ pre-check: |
   # Some script to run before running checks.
   cp eve.json eve.json.bak
 
+# Provide a pcap filename. A falsey value like false or empty is equivalent to setting
+# "pcap: false" in the requires section.
+pcap: input.pcap
+
 checks:
 
   # A verification filter that is run over the eve.json. Multiple
diff --git a/run.py b/run.py
index 2a039b1bf4028765d6e390ea1c01efe946cacc1a..1fc6846e0aa0fe9f2a93ffc8affba017b87b2c2f 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -308,7 +308,7 @@ def check_requires(requires, suricata_config: SuricataConfig):
                     raise UnsatisfiedRequirementError(
                         "requires script returned false")
         elif key == "pcap":
-            # Handle below...
+            # A valid requires argument, but not verified here.
             pass
         else:
             raise Exception("unknown requires types: %s" % (key))
@@ -583,6 +583,13 @@ class TestRunner:
                 pcap_required = requires["pcap"]
             else:
                 pcap_required = True
+
+            # As a pcap filename can be specified outside of the requires block, let
+            # setting this to false disable the requirement of a pcap as well.
+            if "pcap" in self.config and not self.config["pcap"]:
+                pcap_required = False
+                del(self.config["pcap"])
+
             if pcap_required and not "pcap" in self.config:
                 if not glob.glob(os.path.join(self.directory, "*.pcap")) + \
                    glob.glob(os.path.join(self.directory, "*.pcapng")):