feat(cli)!: standardize ATT&CK export command#237
Merged
Conversation
… and related tests
- Added slow marker to several tests in `test_cli.py` and `test_layers.py` to categorize them for longer execution times. - Refactored `test_export_excel` in `test_cli.py` to utilize a mock `ToExcel` class for testing Excel export argument wiring. - Improved `test_export_with_memstore_uses_current_dataframe_builder` and `test_export_with_pre_v18_version_uses_legacy_dataframe_builder` in `test_to_excel.py` to validate dataframe building logic based on version. - Introduced new tests in `test_to_excel.py` to verify the creation of expected workbooks, handling of empty data, deduplication of citations, and sanitization of matrix sheet names. - Updated `uv.lock` to require pytest version 9.0 or higher for development dependencies.
…ase directory and improve error handling
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request introduces significant improvements to the CLI interface for exporting ATT&CK data to Excel, refactors documentation and configuration to use consistent command names, and adds support for more efficient local testing. The main highlights are the migration from an
argparse-based CLI to atyper-powered CLI forattack-to-excel, improved documentation and usage examples, and the addition of a fast test subset for development.CLI and API changes:
attackToExcel_clito a newattack-to-excelCLI usingtyper, with subcommandsfrom-stixandfrom-releasefor converting STIX bundles and full releases to Excel, respectively. The CLI now supports more flexible options, improved validation, and better error messages. ([[1]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-8f2d932337938ce9636015b3325fe81857f7f675dfccda2eb7665ecd20914154L1-R213),[[2]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-8f2d932337938ce9636015b3325fe81857f7f675dfccda2eb7665ecd20914154L412-R737))export_releaseAPI and CLI support, allowing batch export of all or selected domains from a release, with automatic downloading of missing STIX bundles and improved directory management. ([mitreattack/attackToExcel/attackToExcel.pyL1-R213](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-8f2d932337938ce9636015b3325fe81857f7f675dfccda2eb7665ecd20914154L1-R213))Documentation updates:
README.mdto reflect the newattack-to-excelcommand and its subcommands, including instructions for exporting from releases and handling missing STIX files. ([[1]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-5d824234059da3003f2d5b57c40ff91cb7bb382834f1781c78c6fb4bb5c28269L13-R46),[[2]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-5d824234059da3003f2d5b57c40ff91cb7bb382834f1781c78c6fb4bb5c28269R59-R66),[[3]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-5d824234059da3003f2d5b57c40ff91cb7bb382834f1781c78c6fb4bb5c28269R80))attack-to-excel,attack-changelog) for consistency across documentation and code. ([[1]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-3f49d028fe4785c8d1221c0022575a1fdb05a055c01c00debe456357f0f949ceL59-R69),[[2]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-eeffd82f346c3a6879b2e2c566bddbcb232daf36cf450bd3fa7659206ba3dc17L162-R162),[[3]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-eeffd82f346c3a6879b2e2c566bddbcb232daf36cf450bd3fa7659206ba3dc17L362-R362),[[4]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-2170661eed8204cb5513e828165e4ffe6f9558f36e978021ec2e65f4d808f83aL1-R1))Testing and developer workflow improvements:
just test-fastcommand and correspondingpytestmarker configuration to support running a fast subset of tests locally, excluding integration and slow tests, and updated contributing guidelines accordingly. ([[1]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-deb9bb56fb122db0b605aa5b63f95a4665c905b18dd670e1fa6c877576a94ff1R38-R41),[[2]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-4c6b93aa75d5affde60dc3849606c9acd75ed444d52e99f3055fc0c7aa77e9e0L54-R61),[[3]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L83-R89))--durations=20flag topytest, helping identify slowest tests. ([.github/workflows/lint-and-test.ymlL50-R50](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-9a979a1e38ba79e2c75e54c4bf21fe1a2a1b935e1736666565f992e634dadd0fL50-R50))Configuration and packaging:
pyproject.tomlto register new CLI entry points (attack-to-excel,attack-changelog), update dependencies, and configurepytestmarkers. ([[1]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L44-R58),[[2]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L83-R89))Minor fixes:
[[1]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-6ae1ed734de765c55aa359c793efe4b367a23180829b5f6e9e98909a9ac5be0eL13-R13),[[2]](https://github.com/mitre-attack/mitreattack-python/pull/237/files#diff-6ae1ed734de765c55aa359c793efe4b367a23180829b5f6e9e98909a9ac5be0eL1432-R1432))These changes modernize the CLI experience, improve developer productivity, and ensure consistency across documentation, code, and continuous integration.