Clusters and elements to attach to MISP events or attributes (like threat actors) https://www.misp-project.org/galaxy.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.6 KiB

  1. #!/bin/bash
  2. # This file launch all validation of the jsons and schemas
  3. # By default, It stop on file not commited.
  4. # you could test with command ./validate_all.sh something
  5. # Check Jsons format, and beautify
  6. ./jq_all_the_things.sh
  7. rc=$?
  8. if [[ $rc != 0 ]]; then
  9. exit $rc
  10. fi
  11. set -e
  12. set -x
  13. diffs=`git status --porcelain | wc -l`
  14. if ! [ $diffs -eq 0 ]; then
  15. echo "Please make sure you run ./jq_all_the_things.sh before commiting."
  16. if [ $# -eq 0 ]; then
  17. exit 1
  18. fi
  19. fi
  20. # remove the exec flag on the json files
  21. find -name "*.json" -exec chmod -x "{}" \;
  22. diffs=`git status --porcelain | wc -l`
  23. if ! [ $diffs -eq 0 ]; then
  24. echo "Please make sure you run remove the executable flag on the json files before commiting: find -name "*.json" -exec chmod -x \"{}\" \\;"
  25. exit 1
  26. fi
  27. # Validate schemas
  28. for dir in clusters/*.json
  29. do
  30. echo -n "${dir}: "
  31. jsonschema -i ${dir} schema_clusters.json
  32. rc=$?
  33. if [[ $rc != 0 ]]; then
  34. echo "Error on ${dir}"
  35. exit $rc
  36. fi
  37. echo ''
  38. done
  39. for dir in galaxies/*.json
  40. do
  41. echo -n "${dir}: "
  42. jsonschema -i ${dir} schema_galaxies.json
  43. rc=$?
  44. if [[ $rc != 0 ]]; then
  45. echo "Error on ${dir}"
  46. exit $rc
  47. fi
  48. echo ''
  49. done
  50. for dir in misp/*.json
  51. do
  52. echo -n "${dir}: "
  53. jsonschema -i ${dir} schema_misp.json
  54. rc=$?
  55. if [[ $rc != 0 ]]; then
  56. echo "Error on ${dir}"
  57. exit $rc
  58. fi
  59. echo ''
  60. done
  61. for dir in vocabularies/*/*.json
  62. do
  63. echo -n "${dir}: "
  64. jsonschema -i ${dir} schema_vocabularies.json
  65. rc=$?
  66. if [[ $rc != 0 ]]; then
  67. echo "Error on ${dir}"
  68. exit $rc
  69. fi
  70. echo ''
  71. done
  72. # check for empyt strings in clusters
  73. python3 -m tools.chk_empty_strings