Skip to content

Commit 0ec91f3

Browse files
committed
chore: add script to generate excel files
1 parent 44d48e0 commit 0ec91f3

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

examples/generate_excel_files.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from mitreattack.attackToExcel import attackToExcel
2+
from stix2 import MemoryStore
3+
import os
4+
5+
def main():
6+
# List of domains and version to process
7+
domains = ["enterprise-attack", "mobile-attack", "ics-attack"]
8+
output_dir = "output/"
9+
10+
# Path to the STIX bundles for each domain (assumes STIX files are downloaded)
11+
stix_base_dir = os.environ.get("STIX_BASE_DIR", "attack-releases/stix-2.0/v17.1")
12+
stix_files = {
13+
"enterprise-attack": os.path.join(stix_base_dir, "enterprise-attack.json"),
14+
"mobile-attack": os.path.join(stix_base_dir, "mobile-attack.json"),
15+
"ics-attack": os.path.join(stix_base_dir, "ics-attack.json"),
16+
}
17+
18+
for domain in domains:
19+
stix_file = stix_files[domain]
20+
print(f"Exporting {domain} to Excel...")
21+
22+
# Load STIX data into MemoryStore
23+
mem_store = MemoryStore()
24+
mem_store.load_from_file(stix_file)
25+
26+
# Export to Excel
27+
attackToExcel.export(
28+
domain=domain,
29+
output_dir=output_dir,
30+
mem_store=mem_store,
31+
)
32+
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
 (0)