Skip to content

Commit b670b47

Browse files
authored
feat: add attack_changelog command for generating changelog artifacts between ATT&CK versions (#236)
1 parent 993f404 commit b670b47

5 files changed

Lines changed: 779 additions & 34 deletions

File tree

examples/generate_multiple_attack_diffs.py

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import argparse
44

5-
from mitreattack.diffStix.changelog_helper import get_new_changelog_md
5+
from mitreattack.diffStix.attack_changelog import generate_attack_changelog
66

77
DOMAINS = ["enterprise-attack", "mobile-attack", "ics-attack"]
88
VERSION_PAIRS = [
@@ -11,17 +11,6 @@
1111
]
1212

1313

14-
def get_release_output_folder(old_version: str, new_version: str) -> str:
15-
"""Return the output folder for a release comparison."""
16-
return f"output/v{old_version}-v{new_version}"
17-
18-
19-
def get_artifact_link_prefix(old_version: str, new_version: str, *, attack_website_links: bool = False) -> str:
20-
"""Return the link prefix for generated layers and changelog JSON."""
21-
if not attack_website_links:
22-
return ""
23-
return f"/docs/changelogs/v{old_version}-v{new_version}"
24-
2514

2615
def get_parsed_args():
2716
"""Parse command line arguments for the example script."""
@@ -37,31 +26,18 @@ def get_parsed_args():
3726

3827
def generate_diff(old_version: str, new_version: str, *, attack_website_links: bool = False):
3928
"""Generate changelog outputs for a single ATT&CK release pair."""
40-
output_folder = get_release_output_folder(old_version, new_version)
29+
output_folder = f"output/v{old_version}-v{new_version}"
4130
print(f"Generating ATT&CK Diffs between {old_version}-{new_version}: {output_folder}")
4231

43-
get_new_changelog_md(
32+
generate_attack_changelog(
33+
old_version=old_version,
34+
new_version=new_version,
4435
domains=DOMAINS,
45-
layers=[
46-
f"{output_folder}/layer-enterprise.json",
47-
f"{output_folder}/layer-mobile.json",
48-
f"{output_folder}/layer-ics.json",
49-
],
50-
old=f"attack-releases/stix-2.0/v{old_version}",
51-
new=f"attack-releases/stix-2.0/v{new_version}",
52-
show_key=True,
53-
# site_prefix: str = "",
36+
output_dir=output_folder,
5437
verbose=True,
55-
include_contributors=True,
56-
markdown_file=f"{output_folder}/changelog.md",
57-
html_file=f"{output_folder}/index.html",
58-
html_file_detailed=f"{output_folder}/changelog-detailed.html",
59-
additional_formats_prefix=get_artifact_link_prefix(
60-
old_version,
61-
new_version,
62-
attack_website_links=attack_website_links,
63-
),
64-
json_file=f"{output_folder}/changelog.json",
38+
markdown_file=True,
39+
html_file=True,
40+
attack_website_links=attack_website_links,
6541
)
6642

6743

mitreattack/diffStix/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ Example execution:
5353
diff_stix -v --show-key --html-file output/changelog.html --html-file-detailed output/changelog-detailed.html --markdown-file output/changelog.md --json-file output/changelog.json --layers output/layer-enterprise.json output/layer-mobile.json output/layer-ics.json --old path/to/old/stix/ --new path/to/new/stix/
5454
```
5555
56+
Generate release changelog artifacts for one ATT&CK version pair:
57+
58+
```shell
59+
attack_changelog --old-version 17.1 --new-version 18.0
60+
```
61+
62+
The `attack_changelog` command reads local release data from `attack-releases/stix-2.0/v{version}` by default.
63+
If either requested release is missing, it downloads the needed STIX bundles into a temporary directory and
64+
removes them when generation is complete.
65+
It always writes detailed HTML, JSON, and Navigator layer artifacts under `output/v{old_version}-v{new_version}`.
66+
It can also generate `changelog.md` or `index.html` if needed by passing the corresponding flags:
67+
68+
```shell
69+
attack_changelog --old-version 17.1 --new-version 18.0 \
70+
--markdown-file \
71+
--html-file
72+
```
73+
5674
## Changelog JSON format
5775
5876
The changelog helper script has the option to output a JSON file with detailed differences between ATT&CK releases.

0 commit comments

Comments
 (0)