Skip to content

Commit

Permalink
Merge pull request #20
Browse files Browse the repository at this point in the history
Schema for Custom Signatures, Improved File Formats Schema, and Dynamic Schema Tests
  • Loading branch information
MatteoCampinoti94 authored Nov 3, 2023
2 parents 31db904 + 525709b commit 94425bf
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 3 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/check-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
51 changes: 51 additions & 0 deletions custom_signatures.schema.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
65 changes: 64 additions & 1 deletion fileformats.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 94425bf

Please sign in to comment.