mirror of
https://github.com/MISP/misp-galaxy.git
synced 2024-11-26 00:37:18 +00:00
Initial Json schema
This commit is contained in:
parent
6fb89a644f
commit
47ac01ee96
10 changed files with 146 additions and 41 deletions
21
.travis.yml
21
.travis.yml
|
@ -1,17 +1,16 @@
|
|||
language: bash
|
||||
language: python
|
||||
|
||||
cache: pip
|
||||
|
||||
python:
|
||||
- "3.6"
|
||||
|
||||
sudo: required
|
||||
|
||||
dist: trusty
|
||||
|
||||
install:
|
||||
- git clone https://github.com/stedolan/jq.git
|
||||
- pushd jq
|
||||
- autoreconf -i
|
||||
- ./configure --disable-maintainer-mode
|
||||
- make
|
||||
- sudo make install
|
||||
- popd
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y -qq jq moreutils
|
||||
- pip install jsonschema
|
||||
|
||||
script:
|
||||
- cat */*.json | jq .
|
||||
- ./validate_all.sh
|
||||
|
|
13
jq_all_the_things.sh
Executable file
13
jq_all_the_things.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Seeds sponge, from moreutils
|
||||
|
||||
for dir in galaxies/*.json
|
||||
do
|
||||
cat ${dir} | jq . | sponge ${dir}
|
||||
done
|
||||
|
||||
cat schema.json | jq . | sponge schema.json
|
72
schema.json
Normal file
72
schema.json
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"title": "Validator for misp-galaxies",
|
||||
"id": "https://www.github.com/MISP/misp-galaxies/schema.json",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
},
|
||||
"values": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"Possible Issues": {
|
||||
"type": "string"
|
||||
},
|
||||
"meta": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"value"
|
||||
]
|
||||
}
|
||||
},
|
||||
"authors": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"description",
|
||||
"type",
|
||||
"version",
|
||||
"name",
|
||||
"uuid",
|
||||
"values",
|
||||
"authors",
|
||||
"source"
|
||||
]
|
||||
}
|
21
validate_all.sh
Executable file
21
validate_all.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
./jq_all_the_things.sh
|
||||
|
||||
diffs=`git status --porcelain | wc -l`
|
||||
|
||||
if ! [ $diffs -eq 0 ]; then
|
||||
echo "Please make sure you run ./jq_all_the_things.sh before commiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dir in galaxies/*.json
|
||||
do
|
||||
echo -n "${dir}: "
|
||||
jsonschema -i ${dir} schema.json
|
||||
echo ''
|
||||
done
|
||||
|
Loading…
Reference in a new issue