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
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")
# 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:
+++ /dev/null
-{
- "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"
- }
- }
- }
- }
-}