From: Jason Ish Date: Thu, 4 Aug 2022 16:20:14 +0000 (-0600) Subject: runner: don't fail if the pcap filename is falsey X-Git-Tag: suricata-6.0.8~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce4a1c7c597a95eec70a58b4f58fcda6a63e453d;p=thirdparty%2Fsuricata-verify.git runner: don't fail if the pcap filename is falsey 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. --- diff --git a/README.md b/README.md index e03860333..cc4f390c4 100644 --- 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 2a039b1bf..1fc6846e0 100755 --- 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")):