diff options
Diffstat (limited to 'src/schema.py')
-rw-r--r-- | src/schema.py | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/schema.py b/src/schema.py deleted file mode 100644 index 37da5aa..0000000 --- a/src/schema.py +++ /dev/null @@ -1,75 +0,0 @@ -import json - -import jsonschema - -schema = { - "$schema": "http://json-schema.org/schema#", - "type": "object", - "properties": { - "document_version": { - "type": "integer" - }, - "ip": { - "type": "string" - }, - "port": { - "type": "integer" - }, - "whois_description": { - "type": "string" - }, - "asn": { - "type": "string" - }, - "asn_country_code": { - "type": "string" - }, - "ptr": { - "type": "string" - }, - "abuse_mail": { - "type": "string" - }, - "domain": { - "type": "string" - }, - "timestamp_in_utc": { - "type": "string" - }, - "user_presentation": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "data": { - "type": "object" - } - } - } - }, - "required": [ - "document_version", - "ip", - "port", - "timestamp_in_utc", - "user_presentation" - ] -} - - -def validate_collector_data(json_blob): - try: - jsonschema.validate(json_blob, schema) - except jsonschema.exceptions.ValidationError as e: - print(f'Validation failed with error: {e}') - return False - - return True - - -if __name__ == '__main__': - with open('example_data.json') as fd: - json_data = json.loads(fd.read()) - - validate_collector_data(json_data) |