Skip to content

Commit 99d43f3

Browse files
committed
feat: add overwrite option for Excel file exports
- Introduced an `--overwrite` flag in CLI commands to allow users to replace existing Excel files during export. - Enhanced logging to inform users when existing files are being overwritten. - Updated the `write_excel` function to handle overwriting of existing files and log actions accordingly. - Modified tests to cover scenarios for overwriting existing files and logging behavior. - Updated dependencies to include `click` version 8.1.8 for improved CLI functionality.
1 parent f684d40 commit 99d43f3

6 files changed

Lines changed: 788 additions & 53 deletions

File tree

mitreattack/attackToExcel/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ Build Excel files for selected ATT&CK domains from a release:
4646
attack-to-excel from-release --version v19.0 --domains mobile-attack --domains ics-attack
4747
```
4848

49+
`attack-to-excel` refuses to run when generated output directories already
50+
contain Excel files. Pass `--overwrite` to `from-stix` or `from-release` to
51+
replace existing Excel files. Pass `-v` or `--verbose` to show debug logs,
52+
including sheet-level write messages.
53+
4954
### Module
5055

5156
Example execution targeting a specific domain and version:
@@ -75,9 +80,9 @@ overview of the available methods follows.
7580
|:------------|:----------|:------|
7681
|get_stix_data|`domain`: the domain of ATT&CK to fetch data from <br> `version`: optional parameter indicating which version to fetch data from (such as "v8.1"). If omitted retrieves the most recent version of ATT&CK. <br>`remote`: optional parameter that provides a URL of a remote ATT&CK Workbench instance to grab data from.| Retrieves the ATT&CK STIX data for the specified version and returns it as a MemoryStore object|
7782
|build_dataframes| `src`: MemoryStore or other stix2 DataSource object holding domain data<br> `domain`: domain of ATT&CK that `src` corresponds to| Builds a Pandas DataFrame collection as a dictionary, with keys for each type, based on the ATT&CK data provided|
78-
|write_excel| `dataframes`: pandas DataFrame dictionary (generated by build_dataframes) <br> `domain`: domain of ATT&CK that `dataframes` corresponds to <br> `version`: optional parameter indicating which version of ATT&CK is in use <br> `output_dir`: optional parameter specifying output directory| Writes out DataFrame based ATT&CK data to excel files|
79-
|export| `domain`: the domain of ATT&CK to download <br> `version`: optional parameter specifying which version of ATT&CK to download <br> `output_dir`: optional parameter specifying output directory| Downloads ATT&CK data from MITRE/CTI and exports it to Excel spreadsheets |
80-
|export_release| `version`: optional ATT&CK release version <br> `stix_version`: STIX release tree, such as "2.0" or "2.1" <br> `output_dir`: parent output directory <br> `stix_base_dir`: optional directory containing release STIX files <br> `domains`: optional list of domains <br> `versioned_output_dir`: preserve domain-version output folders| Exports a full ATT&CK release to Excel spreadsheets, downloading missing STIX files temporarily when needed |
83+
|write_excel| `dataframes`: pandas DataFrame dictionary (generated by build_dataframes) <br> `domain`: domain of ATT&CK that `dataframes` corresponds to <br> `version`: optional parameter indicating which version of ATT&CK is in use <br> `output_dir`: optional parameter specifying output directory <br> `overwrite`: optional parameter allowing existing Excel files to be replaced| Writes out DataFrame based ATT&CK data to excel files|
84+
|export| `domain`: the domain of ATT&CK to download <br> `version`: optional parameter specifying which version of ATT&CK to download <br> `output_dir`: optional parameter specifying output directory <br> `overwrite`: optional parameter allowing existing Excel files to be replaced| Downloads ATT&CK data from MITRE/CTI and exports it to Excel spreadsheets |
85+
|export_release| `version`: optional ATT&CK release version <br> `stix_version`: STIX release tree, such as "2.0" or "2.1" <br> `output_dir`: parent output directory <br> `stix_base_dir`: optional directory containing release STIX files <br> `domains`: optional list of domains <br> `versioned_output_dir`: preserve domain-version output folders <br> `overwrite`: optional parameter allowing existing Excel files to be replaced| Exports a full ATT&CK release to Excel spreadsheets, downloading missing STIX files temporarily when needed |
8186

8287
### stixToDf
8388

0 commit comments

Comments
 (0)