INNER CODE UNIT · Python
collections
mitre-attack/attack-stix-data · util/generate-collection-index.py:33
collections = {} # STIX ID -> collection object
for collection_bundle_file in tqdm(files, desc="parsing collections"):
with open(collection_bundle_file, "r") as f:
bundle = json.load(f)
for collection_version in filter(lambda x: x["type"] == "x-mitre-collection", bundle["objects"]):
# parse collection
if collection_version["id"] not in collections:
# create
collections[collection_version["id"]] = {
"id": collection_version["id"],
"created": collection_version["created"], # created is the same for all versions
"versions": []
}
collection = collections[collection_version["id"]]
# append this as a version
collection["versions"].append({