Add testing, update travis

pull/7/head
Raphaël Vinot 2017-02-13 11:15:51 +01:00
parent 4f40e2e497
commit 1f2633c6f1
4 changed files with 74 additions and 11 deletions

View File

@ -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
- pip install jsonschema
script:
- cat */*/*.json | jq .
- ./validate_all.sh

13
jq_all_the_things.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
set -x
# Seeds sponge, from moreutils
for dir in objects/*/list.json
do
cat ${dir} | jq . | sponge ${dir}
done
cat schema.json | jq . | sponge schema.json

30
schema.json Normal file
View File

@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "Validator for misp-objects",
"id": "https://www.github.com/MISP/misp-objects/schema.json",
"type": "object",
"properties": {
"meta-category": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"version": {
"type": "integer"
},
"attributes": {
"type": "object"
}
},
"required": [
"attributes",
"version",
"description",
"meta-category",
"name"
]
}

21
validate_all.sh Executable file
View 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 objects/*/list.json
do
echo -n "${dir}: "
jsonschema -i ${dir} schema.json
echo ''
done