From: Jason Ish Date: Tue, 26 Oct 2021 15:50:04 +0000 (-0600) Subject: runner: only validate eve if jsonschema is available X-Git-Tag: suricata-6.0.4~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4560f6a237446f59e807408fb2f65ff97f8f6acc;p=thirdparty%2Fsuricata-verify.git runner: only validate eve if jsonschema is available We can only validate eve output if the jsonschema Python module is available. Instead of requiring it at this time, print out a warning and skip the test. --- diff --git a/run.py b/run.py index 6024de9dd..8758471a5 100755 --- a/run.py +++ b/run.py @@ -44,6 +44,13 @@ import filecmp import subprocess import yaml +# Check if we can validate EVE files against the schema. +try: + import jsonschema + VALIDATE_EVE = True +except: + VALIDATE_EVE = False + WIN32 = sys.platform == "win32" LINUX = sys.platform.startswith("linux") suricata_bin = "src\suricata.exe" if WIN32 else "./src/suricata" @@ -650,9 +657,10 @@ class TestRunner: check_value = self.check() - check_output = subprocess.call(["{}/check-eve.py".format(TOPDIR), outdir, "-q"]) - if check_output != 0: - raise TestError("Invalid JSON schema") + if VALIDATE_EVE: + check_output = subprocess.call(["{}/check-eve.py".format(TOPDIR), outdir, "-q"]) + if check_output != 0: + raise TestError("Invalid JSON schema") if not check_value["failure"] and not check_value["skipped"]: if not self.quiet: @@ -925,6 +933,8 @@ def main(): if args.self_test: return unittest.main(argv=[sys.argv[0]]) + print("Warning: EVE files will not be valided: jsonschema module not found.") + TOPDIR = os.path.abspath(os.path.dirname(sys.argv[0])) skipped = 0