mirror of
https://github.com/MISP/misp-galaxy.git
synced 2024-11-26 16:57:18 +00:00
modify validators to check json an format, stop on any error
This commit is contained in:
parent
644e429110
commit
2c263b91de
2 changed files with 39 additions and 11 deletions
|
@ -1,17 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Seeds sponge, from moreutils
|
||||||
|
|
||||||
|
#Validate all Jsons first
|
||||||
|
for dir in `find . -name "*.json"`
|
||||||
|
do
|
||||||
|
echo validating ${dir}
|
||||||
|
cat ${dir} | jq . >/dev/null
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc != 0 ]]; then exit $rc; fi
|
||||||
|
done
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Seeds sponge, from moreutils
|
|
||||||
|
|
||||||
for dir in clusters/*.json
|
for dir in clusters/*.json
|
||||||
do
|
do
|
||||||
|
# Beautify it
|
||||||
cat ${dir} | jq . | sponge ${dir}
|
cat ${dir} | jq . | sponge ${dir}
|
||||||
done
|
done
|
||||||
|
|
||||||
for dir in galaxies/*.json
|
for dir in galaxies/*.json
|
||||||
do
|
do
|
||||||
|
# Beautify it
|
||||||
cat ${dir} | jq . | sponge ${dir}
|
cat ${dir} | jq . | sponge ${dir}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,34 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check Jsons format, and beautify
|
||||||
|
./jq_all_the_things.sh
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc != 0 ]]; then
|
||||||
|
exit $rc
|
||||||
|
fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
./jq_all_the_things.sh
|
# fixme to remove..
|
||||||
|
# Not need anymore ow, jq stop upon error...
|
||||||
diffs=`git status --porcelain | wc -l`
|
# diffs=`git status --porcelain | wc -l`
|
||||||
|
#
|
||||||
if ! [ $diffs -eq 0 ]; then
|
#if ! [ $diffs -eq 0 ]; then
|
||||||
echo "Please make sure you run ./jq_all_the_things.sh before commiting."
|
# echo "Please make sure you run ./jq_all_the_things.sh before commiting."
|
||||||
exit 1
|
# exit
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
|
# Validate schemas
|
||||||
for dir in clusters/*.json
|
for dir in clusters/*.json
|
||||||
do
|
do
|
||||||
echo -n "${dir}: "
|
echo -n "${dir}: "
|
||||||
jsonschema -i ${dir} schema_clusters.json
|
jsonschema -i ${dir} schema_clusters.json
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc != 0 ]]; then
|
||||||
|
echo "Error on ${dir}"
|
||||||
|
exit $rc
|
||||||
|
fi
|
||||||
echo ''
|
echo ''
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -23,6 +36,10 @@ for dir in galaxies/*.json
|
||||||
do
|
do
|
||||||
echo -n "${dir}: "
|
echo -n "${dir}: "
|
||||||
jsonschema -i ${dir} schema_galaxies.json
|
jsonschema -i ${dir} schema_galaxies.json
|
||||||
|
rc=$?
|
||||||
|
if [[ $rc != 0 ]]; then
|
||||||
|
echo "Error on ${dir}"
|
||||||
|
exit $rc
|
||||||
|
fi
|
||||||
echo ''
|
echo ''
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue