DeFi Incidents in STIX 2.1.
cd python-scripts
python3 -m venv menpo_env
source menpo_env/bin/activate
pip3 install -r requirements.txt # If first time
cd python-scripts/data-input
python3 <stix2 python script>
Example
cd python-scripts/data-input
source menpo_env/bin/activate
python3 22.09.01.kyberswap.py
import json
from stix2 import FileSystemSource, Filter
from stix2.base import STIXJSONEncoder
fs = FileSystemSource("../../db")
# Do the query
filt = Filter('type', '=', 'report')
reports = fs.query([filt])
# Convert the Python objects to JSON and print them
json_str = json.dumps(reports, indent=4, cls=STIXJSONEncoder)
print(json_str)
# Or, if you don't like json, we can give you a more compact one
sorted_reports = sorted(reports, key=lambda x: x["published"])
print("Reports in the DB:", len(sorted_reports), "\n")
for report in sorted_reports:
print("-", report.name)
# TODO