]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
schema.json: use file from suriceta source tree
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 12 May 2022 18:42:07 +0000 (20:42 +0200)
committerJason Ish <jason.ish@oisf.net>
Fri, 3 Jun 2022 19:55:44 +0000 (13:55 -0600)
check-eve.py
run.py
schema.json [deleted file]

index 92cebd7689054ecbdb0c18a1cdc23631d723931e..5f4a408c9ff3a0bcda0431f8f79edc4353f3ac90 100755 (executable)
@@ -69,16 +69,15 @@ def main():
     parser.add_argument("-p", dest="python_validator", action="store_true", help="use python validator")
     parser.add_argument("file", nargs="?", default=[])
     parser.add_argument("-q", dest="quiet", action="store_true")
+    parser.add_argument("-s", dest="schema", action="store")
     args = parser.parse_args()
     TOPDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
     tdir = os.path.join(TOPDIR, "tests")
 
-    json_path = "{}/schema.json".format(TOPDIR)
-
     if args.python_validator:
-        schema = json.load(open(json_path))
+        schema = json.load(open(args.schema))
     else:
-        schema = json_path
+        schema = args.schema
 
     checked = 0
     passed = 0
diff --git a/run.py b/run.py
index 8b8845904a8dea9ad05b29dd624a56b39c771655..c2570bad40c22dec7ad568fece5b70328f1f07b9 100755 (executable)
--- a/run.py
+++ b/run.py
@@ -676,7 +676,7 @@ class TestRunner:
             check_value = self.check()
 
         if VALIDATE_EVE:
-            check_output = subprocess.call(["{}/check-eve.py".format(TOPDIR), outdir, "-q"])
+            check_output = subprocess.call(["{}/check-eve.py".format(TOPDIR), outdir, "-q", "-s", os.path.join(self.cwd, "schema.json")])
             if check_output != 0:
                 raise TestError("Invalid JSON schema")
 
@@ -975,6 +975,10 @@ def main():
     # only validate eve since version 7
     if not is_version_compatible(version="7", suri_version=suricata_config.version, expr="gte"):
         VALIDATE_EVE = False
+    if VALIDATE_EVE:
+        if not os.path.exists(os.path.join(cwd, "schema.json")):
+            print("Warning: No schema.json to validate eve.")
+            VALIDATE_EVE = False
     suricata_config.valgrind = args.valgrind
     tdir = os.path.join(TOPDIR, "tests")
     if args.testdir:
diff --git a/schema.json b/schema.json
deleted file mode 100644 (file)
index 9a1c9bd..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-{
-    "type": "object",
-    "properties": {
-        "timestamp": {
-            "type": "string",
-            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d+[+\\-]\\d+$",
-            "optional": false
-        },
-        "flow_id": {
-            "type": "integer",
-            "optional": true
-        },
-        "pcap_cnt": {
-            "type": "integer",
-            "optional": true
-        },
-        "event_type": {
-            "type": "string",
-            "optional": false
-        },
-        "vlan": {
-            "type": "array",
-            "items": {
-                "type": "number"
-            }
-        },
-        "src_ip": {
-            "type": "string",
-            "optional": true
-        },
-        "src_port": {
-            "type": "integer",
-            "optional": true
-        },
-        "dest_ip": {
-            "type": "string",
-            "optional": true
-        },
-        "dest_port": {
-            "type": "integer",
-            "optional": true
-        },
-        "proto": {
-            "type": "string",
-            "optional": true
-        },
-        "http": {
-            "type": "object",
-            "optional": true,
-            "properties": {
-                "hostname": {
-                    "type": "string"
-                },
-                "url": {
-                    "type": "string"
-                },
-                "http_user_agent": {
-                    "type": "string"
-                },
-                "http_content_type": {
-                    "type": "string"
-                },
-                "http_method": {
-                    "type": "string"
-                },
-                "protocol": {
-                    "type": "string"
-                },
-                "status": {
-                    "type": "integer"
-                },
-                "length": {
-                    "type": "integer"
-                }
-            }
-        },
-        "app_proto": {
-            "type": "string",
-            "optional": true
-        },
-        "fileinfo": {
-            "type": "object",
-            "optional": true,
-            "properties": {
-                "filename": {
-                    "type": "string"
-                },
-                "state": {
-                    "type": "string"
-                },
-                "stored": {
-                    "type": "boolean"
-                },
-                "size": {
-                    "type": "integer"
-                },
-                "tx_id": {
-                    "type": "integer"
-                }
-            }
-        }
-    }
-}