From: Philippe Antoine Date: Thu, 12 May 2022 18:42:07 +0000 (+0200) Subject: schema.json: use file from suriceta source tree X-Git-Tag: suricata-5.0.10~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81ffc2f00b74192f51fba6744cc07d3123c4222b;p=thirdparty%2Fsuricata-verify.git schema.json: use file from suriceta source tree --- diff --git a/check-eve.py b/check-eve.py index 92cebd768..5f4a408c9 100755 --- a/check-eve.py +++ b/check-eve.py @@ -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 8b8845904..c2570bad4 100755 --- 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 index 9a1c9bdc0..000000000 --- a/schema.json +++ /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" - } - } - } - } -}