MISP/tests/build-test.sh

28 lines
1.9 KiB
Bash
Raw Normal View History

2021-10-09 11:04:03 +02:00
#!/usr/bin/env bash
set -e
set -o xtrace
# Check if dependencies for zmq are properly installed
2023-05-12 15:36:05 +02:00
python ./../app/files/scripts/mispzmq/mispzmqtest.py
2021-10-09 11:04:03 +02:00
# Check if all attachments handlers dependencies are correctly installed
2023-11-11 14:08:21 +01:00
python ./../app/files/scripts/generate_file_objects.py -c | python3 -c 'import sys, json; data = json.load(sys.stdin); print(data); sys.exit(0 if len([i for i in data.values() if i is not False]) == 0 else 1)'
2021-10-09 11:04:03 +02:00
# Try to extract data from file
2023-05-12 15:36:05 +02:00
python ./../app/files/scripts/generate_file_objects.py -p /bin/ls | python3 -c 'import sys, json; data = json.load(sys.stdin); sys.exit(0 if "objects" in data else 1)'
2021-10-09 11:04:03 +02:00
# Test converting stix1 to MISP format
2024-01-27 16:17:11 +01:00
curl -sS --compressed https://stixproject.github.io/documentation/idioms/c2-indicator/indicator-for-c2-ip-address.xml > ./../app/files/scripts/tmp/test-stix1.xml
2023-05-12 15:36:05 +02:00
python ./../app/files/scripts/stix2misp.py test-stix1.xml 1 1 ./../app/files/scripts/synonymsToTagNames.json | python3 -c 'import sys, json; data = json.load(sys.stdin); print(data); sys.exit(0 if data["success"] == 1 else 1)'
2021-10-09 11:04:03 +02:00
rm -f ./../app/files/scripts/tmp/{test-stix1.xml,test-stix1.xml.json}
# Test converting stix2 to MISP format
2024-01-27 16:17:11 +01:00
curl -sS --compressed https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/master/examples/indicator-for-c2-ip-address.json > ./../app/files/scripts/tmp/test-stix2.json
2023-05-12 15:36:05 +02:00
python ./../app/files/scripts/stix2/stix2misp.py -i ./../app/files/scripts/tmp/test-stix2.json --distribution 1 | python3 -c 'import sys, json; data = json.load(sys.stdin); print(data); sys.exit(0 if data["success"] == 1 else 1)'
2021-10-09 11:04:03 +02:00
rm -f ./../app/files/scripts/tmp/{test-stix2.json,test-stix2.json.stix2}
# Test converting MISP to STIX2
cp event.json /tmp/
2023-05-12 15:36:05 +02:00
python ./../app/files/scripts/stix2/misp2stix2.py -i /tmp/event.json | python3 -c 'import sys, json; data = json.load(sys.stdin); print(data); sys.exit(0 if data["success"] == 1 else 1)'
rm -f /tmp/{event.json,event.json.out}