diff --git a/.github/workflows/check-json.yml b/.github/workflows/check-json.yml index ccd8e55..ecea4be 100644 --- a/.github/workflows/check-json.yml +++ b/.github/workflows/check-json.yml @@ -25,5 +25,19 @@ jobs: uses: limitusus/json-syntax-check@v2 with: pattern: "\\.json$" - - name: Check Actions Schema - run: python -c 'import yaml,json,jsonschema,sys;jsonschema.validate(yaml.load(open(sys.argv[1]), yaml.Loader), json.load(open(sys.argv[2])))' fileformats.yml fileformats.schema.json \ No newline at end of file + - name: Check JSON Schemata + run: | + for schema in *.schema.json; do + if [[ -f "${schema%.schema.json}.json" ]]; then + python3 -c 'import json,jsonschema,sys;jsonschema.validate(json.load(open(sys.argv[1])), json.load(open(sys.argv[2])))' "${schema%.schema.json}.json" "$schema"; + fi; + done + - name: Check YAML Schemata + run: | + for schema in *.schema.json; do + for ext in "yaml" "yml"; do + if [[ -f "${schema%.schema.json}.$ext" ]]; then + python3 -c 'import yaml,json,jsonschema,sys;jsonschema.validate(yaml.load(open(sys.argv[1]), yaml.Loader), json.load(open(sys.argv[2])))' "${schema%.schema.json}.$ext" "$schema"; + fi; + done + done \ No newline at end of file diff --git a/custom_signatures.schema.json b/custom_signatures.schema.json new file mode 100644 index 0000000..b9a2c4d --- /dev/null +++ b/custom_signatures.schema.json @@ -0,0 +1,51 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "actions", + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "dependencies": { + "operator": [ + "bof", + "eof" + ] + }, + "if": { + "required": [ + "bof", + "eof" + ] + }, + "then": { + "required": [ + "operator" + ] + }, + "properties": { + "bof": { + "type": "string" + }, + "eof": { + "type": "string" + }, + "operator": { + "type": "string", + "enum": [ + "AND", + "OR", + "XOR" + ] + }, + "puid": { + "type": "string" + }, + "signature": { + "type": "string" + }, + "extension": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/fileformats.schema.json b/fileformats.schema.json index b7d8aad..e30373f 100644 --- a/fileformats.schema.json +++ b/fileformats.schema.json @@ -2,13 +2,76 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "actions", "type": "object", + "additionalProperties": false, "patternProperties": { - ".*": { + "^[a-zA-Z0-9_/-]+$": { "type": "object", "required": [ "name", "action" ], + "oneOf": [ + { + "properties": { + "action": { + "const": "convert" + } + }, + "required": [ + "convert" + ] + }, + { + "properties": { + "action": { + "const": "extract" + } + }, + "required": [ + "extract" + ] + }, + { + "properties": { + "action": { + "const": "manual" + } + }, + "required": [ + "manual" + ] + }, + { + "properties": { + "action": { + "const": "rename" + } + }, + "required": [ + "rename" + ] + }, + { + "properties": { + "action": { + "const": "ignore" + } + }, + "required": [ + "ignore" + ] + }, + { + "properties": { + "action": { + "const": "reidentify" + } + }, + "required": [ + "reidentify" + ] + } + ], "properties": { "name": { "type": "string"