]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
runner: only validate eve if jsonschema is available
authorJason Ish <jason.ish@oisf.net>
Tue, 26 Oct 2021 15:50:04 +0000 (09:50 -0600)
committerJason Ish <jason.ish@oisf.net>
Fri, 12 Nov 2021 22:07:28 +0000 (16:07 -0600)
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.

run.py

diff --git a/run.py b/run.py
index 6024de9dd7493a66bcec2a5967ea731641615a55..8758471a58cfa83ae982489da785aec9350b98f3 100755 (executable)
--- 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