diff options
-rw-r--r-- | example_data_1.json | 2 | ||||
-rw-r--r-- | example_data_2.json | 2 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | src/schema.py | 6 |
4 files changed, 6 insertions, 5 deletions
diff --git a/example_data_1.json b/example_data_1.json index 5c9dcae..69f5d85 100644 --- a/example_data_1.json +++ b/example_data_1.json @@ -8,7 +8,7 @@ "ptr": "host10.test.soc.sunet.se", "abuse_mail": "abuse@test.soc.sunet.se", "domain": "sunet.se", - "timestamp_in_utc": "2021-06-21T14:06 UTC", + "timestamp": "2021-06-21T14:06:00Z", "display_name": "Apache 2.1.3", "description": "The Apache HTTP Server is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0.", "custom_data": { diff --git a/example_data_2.json b/example_data_2.json index 90e3f0a..11c7e61 100644 --- a/example_data_2.json +++ b/example_data_2.json @@ -8,7 +8,7 @@ "ptr": "host11.test.soc.sunet.se", "abuse_mail": "abuse@test.soc.sunet.se", "domain": "sunet.se", - "timestamp_in_utc": "2021-06-30T10:00 UTC", + "timestamp": "2021-06-30T10:00:00Z", "display_name": "VMware ESXi 6.7.0 build-17700523", "description": "VMware ESXi is an enterprise-class, type-1 hypervisor developed by VMware for deploying and serving virtual computers. As a type-1 hypervisor, ESXi is not a software application that is installed on an operating system; instead, it includes and integrates vital OS components, such as a kernel.", "custom_data": { diff --git a/requirements.txt b/requirements.txt index ce2f921..327c7d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,6 +21,7 @@ PyJWT==1.7.1 pyparsing==3.0.6 pytest==6.2.5 requests==2.26.0 +rfc3339-validator==0.1.4 sniffio==1.2.0 starlette==0.16.0 toml==0.10.2 diff --git a/src/schema.py b/src/schema.py index 9bdf130..fe2b76c 100644 --- a/src/schema.py +++ b/src/schema.py @@ -20,7 +20,7 @@ schema = { "ptr": {"type": "string"}, "abuse_mail": {"type": "string"}, "domain": {"type": "string"}, - "timestamp_in_utc": {"type": "string"}, + "timestamp": {"type": "string", "format": "date-time"}, "display_name": {"type": "string"}, "description": {"type": "string"}, "custom_data": { @@ -85,7 +85,7 @@ schema = { "ptr", "abuse_mail", "domain", - "timestamp_in_utc", + "timestamp", "display_name", # "description", # "custom_data", @@ -122,7 +122,7 @@ def as_index_list(): def validate_collector_data(json_blob): try: - jsonschema.validate(json_blob, schema) + jsonschema.validate(json_blob, schema, format_checker=jsonschema.FormatChecker()) except jsonschema.exceptions.ValidationError as e: return f"Validation failed with error: {e.message}" return "" |