]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
run: handle moved classificaton/reference config
authorJason Ish <jason.ish@oisf.net>
Tue, 1 Oct 2019 21:39:28 +0000 (15:39 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 10 Oct 2019 14:28:18 +0000 (16:28 +0200)
First look for these configuration files in ./etc, then in the
top directory to handle the change of location in Suricata 5.0,
as well as work with older versions.

run.py

diff --git a/run.py b/run.py
index 17721e431be5e174541efa5930b5467e3beecf94..111b4bc4ddd94d636e86c711eeaf462592534b36 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -683,12 +683,32 @@ class TestRunner:
             for arg in self.config["args"]:
                 args += re.split("\s", arg)
 
+        # In Suricata 5.0 the classification.config and
+        # reference.config were moved into the etc/ directory. For now
+        # check there and the top level directory to still support
+        # 4.1.
+        classification_configs = [
+            os.path.join(self.cwd, "etc", "classification.config"),
+            os.path.join(self.cwd, "classification.config"),
+        ]
+
+        for config in classification_configs:
+            if os.path.exists(config):
+                args += ["--set", "classification-file=%s" % config]
+                break
+
+        reference_configs = [
+            os.path.join(self.cwd, "etc", "reference.config"),
+            os.path.join(self.cwd, "reference.config"),
+        ]
+
+        for config in reference_configs:
+            if os.path.exists(config):
+                args += ["--set", "reference-config-file=%s" % config]
+                break
+
         # Add other fixed arguments.
         args += [
-            "--set", "classification-file=%s" % os.path.join(
-                self.cwd, "classification.config"),
-            "--set", "reference-config-file=%s" % os.path.join(
-                self.cwd, "reference.config"),
             "--init-errors-fatal",
             "-l", self.output,
         ]