Skip to content

Commit 81f2e4f

Browse files
authored
add clarification to download_attack_versions with examples
1 parent e5bb2b3 commit 81f2e4f

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

mitreattack/download_stix.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def download_stix(stix_version: str, domain: str, download_dir: str, release: st
4141

4242

4343
def download_domains(
44-
domains: List[str], download_dir: str, all_versions: bool, stix_version: str, specific_versions: List[str] = None
44+
domains: List[str], download_dir: str, all_versions: bool, stix_version: str, attack_versions: List[str] = None
4545
):
4646
"""Download ATT&CK domains specified.
4747
@@ -55,8 +55,8 @@ def download_domains(
5555
Whether or not to download all versions of the domains.
5656
stix_version : str
5757
Version of STIX to download. Options are "2.0" or "2.1"
58-
specific_versions : List[str], optional
59-
List of specific versions to download. If provided, overrides all_versions behavior.
58+
attack_versions : List[str], optional
59+
List of specific ATT&CK versions to download. If provided, overrides all_versions behavior.
6060
"""
6161
for domain in domains:
6262
if domain == "pre" and stix_version == "2.1":
@@ -79,10 +79,10 @@ def download_domains(
7979
if stix_version == "2.0":
8080
releases = stix_hash_data["pre"]
8181

82-
if specific_versions:
83-
# Download specific versions
84-
logger.info(f"Downloading STIX {stix_version} specific versions for the {domain} domain to {download_dir}")
85-
for version in specific_versions:
82+
if attack_versions:
83+
# Download ATT&CK versions
84+
for version in attack_versions:
85+
logger.info(f"Downloading STIX {stix_version}, ATT&CK version {version} for the {domain} domain to {download_dir}")
8686
if version in releases:
8787
known_hash = releases[version]
8888
download_stix(
@@ -177,7 +177,7 @@ def download_attack_stix(
177177
all_versions: bool = typer.Option(
178178
False, "--all", "-a", help="Download all ATT&CK releases. Mutually exclusive with --version."
179179
),
180-
versions: List[str] = typer.Option(
180+
attack_versions: List[str] = typer.Option(
181181
None,
182182
"--version",
183183
"-v",
@@ -189,16 +189,34 @@ def download_attack_stix(
189189
"""Download the ATT&CK STIX data from GitHub in JSON format.
190190
191191
By default, only the latest ATT&CK release will be downloaded in STIX 2.0 format.
192-
Use --version to specify particular versions, or --all to download all versions.
192+
Use --version to specify particular ATT&CK versions, or --all to download all ATT&CK versions.
193+
194+
\b
195+
Examples:
196+
\b
197+
# Download latest version:
198+
download_attack_stix
199+
\b
200+
# Download specific versions:
201+
download_attack_stix -v 16.1
202+
\b
203+
# Download all ATT&CK versions in both STIX formats:
204+
download_attack_stix --all --stix21
205+
\b
206+
# Download only STIX 2.1:
207+
download_attack_stix --no-stix20 --stix21
208+
\b
209+
# Download multiple versions:
210+
download_attack_stix -d my-attack-data -v 13.1 -v 14.0 -v 15.0 --stix21
193211
"""
194212
# Validate mutually exclusive options
195-
if all_versions and versions:
213+
if all_versions and attack_versions:
196214
logger.error("Cannot specify both --all and --version. Use one or the other.")
197215
raise typer.Exit(code=1)
198216

199-
# Validate specified versions exist
200-
if versions:
201-
_validate_versions(versions, stix20, stix21)
217+
# Validate specified ATT&CK versions exist
218+
if attack_versions:
219+
_validate_versions(attack_versions, stix20, stix21)
202220

203221
domains = ["enterprise", "mobile", "ics", "pre"]
204222

@@ -210,7 +228,7 @@ def download_attack_stix(
210228
download_dir=stix20_download_dir,
211229
all_versions=all_versions,
212230
stix_version="2.0",
213-
specific_versions=versions,
231+
attack_versions=attack_versions,
214232
)
215233

216234
if stix21:
@@ -221,5 +239,5 @@ def download_attack_stix(
221239
download_dir=stix21_download_dir,
222240
all_versions=all_versions,
223241
stix_version="2.1",
224-
specific_versions=versions,
242+
attack_versions=attack_versions,
225243
)

0 commit comments

Comments
 (0)