From dc1dce796e358fb52c96c095a723edf1ff7a7470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 11 Aug 2017 12:19:52 +0200 Subject: [PATCH] Add schema for relationships --- jq_all_the_things.sh | 5 ++- schema.json => schema_objects.json | 0 schema_relationships.json | 61 ++++++++++++++++++++++++++++++ validate_all.sh | 4 +- 4 files changed, 68 insertions(+), 2 deletions(-) rename schema.json => schema_objects.json (100%) create mode 100644 schema_relationships.json diff --git a/jq_all_the_things.sh b/jq_all_the_things.sh index e10e2d7..78d58b9 100755 --- a/jq_all_the_things.sh +++ b/jq_all_the_things.sh @@ -10,4 +10,7 @@ do cat ${dir} | jq . | sponge ${dir} done -cat schema.json | jq . | sponge schema.json +cat relationships/definition.json | jq . | sponge relationships/definition.json + +cat schema_objects.json | jq . | sponge schema_objects.json +cat schema_relationships.json | jq . | sponge schema_relationships.json diff --git a/schema.json b/schema_objects.json similarity index 100% rename from schema.json rename to schema_objects.json diff --git a/schema_relationships.json b/schema_relationships.json new file mode 100644 index 0000000..22bb0fd --- /dev/null +++ b/schema_relationships.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/schema#", + "title": "Validator for misp-objects", + "id": "https://www.github.com/MISP/misp-objects/schema.json", + "defs": { + "value": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "format": { + "type": "array", + "uniqueItems": true, + "items": { + "type": "string" + } + } + }, + "required": [ + "name", + "description", + "format" + ] + } + }, + "type": "object", + "additionalProperties": false, + "properties": { + "version": { + "type": "integer" + }, + "values": { + "type": "array", + "uniqueItems": true, + "items": { + "$ref": "#/defs/value" + } + }, + "description": { + "type": "string" + }, + "uuid": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": [ + "version", + "values", + "description", + "uuid", + "name" + ] +} diff --git a/validate_all.sh b/validate_all.sh index 1a19b51..f1fcb4f 100755 --- a/validate_all.sh +++ b/validate_all.sh @@ -15,8 +15,10 @@ fi for dir in objects/*/definition.json do echo -n "${dir}: " - jsonschema -i ${dir} schema.json + jsonschema -i ${dir} schema_objects.json echo '' done +jsonschema -i relationships/definition.json schema_relationships.json + ./unique_uuid.py