-
Notifications
You must be signed in to change notification settings - Fork 0
usage
This framework supports two modes of operation: Command Line Interface (CLI) for automated analysis and a Web-based Graphical User Interface (GUI) for interactive editing and visualization.
This framework is designed to be used in a "Threat Model as Code" workflow. This means that the threat model is defined in a simple, version-controllable format (Markdown), and the analysis is performed by running a script. This approach has several advantages:
- Version Control: Threat models can be stored in a Git repository, allowing you to track changes over time.
- Automation: The threat modeling process can be integrated into your CI/CD pipeline, allowing you to automatically update your threat model whenever your architecture changes.
- Collaboration: Developers can collaborate on the threat model using the same tools they use for code.
Use the CLI mode for automated threat analysis, report generation, and diagram creation. This is ideal for integration into CI/CD pipelines or batch processing.
-
Edit
threatModel_Template/threat_model.mdto describe your architecture. -
Run the analysis:
(You can omit
python -m threat_analysis --model-file threatModel_Template/threat_model.md --navigator
--model-file threatModel_Template/threat_model.mdif your model file is namedthreatModel_Template/threat_model.mdand is in the root directory.) -
Generate Attack Flow diagrams: Add the
--attack-flowflag to any analysis command to generate optimized Attack Flow.afbfiles for key objectives.This will generate onepython -m threat_analysis --model-file path/to/your_model.md --attack-flow
.afbfile for each of the main objectives (Tampering, Spoofing, Information Disclosure, Repudiation) found in your model, selecting the highest-scoring path for each. -
View the results in the generated
output/folder:- HTML report
- JSON export
- DOT/SVG/HTML diagrams
- MITRE ATT&CK Navigator layer (JSON)
- Optimized Attack Flow
.afbfiles
You can use the following command-line arguments to specify custom paths for the implemented_mitigations.txt and cve_definitions.yml files:
-
--implemented-mitigations-file: Path to the implemented mitigations file. If not provided, the tool will look for a file named 'implemented_mitigations.txt' in the same directory as the model or project. -
--cve-definitions-file: Path to the CVE definitions file. If not provided, the tool will look for a file named 'cve_definitions.yml' in the same directory as the model or project.
Example:
python -m threat_analysis --model-file path/to/your_model.md --implemented-mitigations-file path/to/your/mitigations.txt --cve-definitions-file path/to/your/cves.ymlHere's a more comprehensive example using test files:
python -m threat_analysis --model-file threatModel_Template/threat_model.md \
--navigator \
--attack-flow \
--implemented-mitigations-file tests/implemented_mitigations.txt \
--cve-definitions-file tests/cve_definitions.ymlThe framework excels at handling complex projects with multiple, nested threat models. By structuring your models in directories (e.g., projects/my_app/main.md, projects/my_app/backend/model.md), you can generate a unified, navigable report.
-
Organize your project in the
threatModel_Template/projects/directory (see examples). -
Run the analysis on the project folder:
python -m threat_analysis --project threatModel_Template/projects/example_2
-
Explore the output: A fully interactive, cross-linked HTML report will be generated in the
output/directory. Diagrams for sub-models are placed in corresponding sub-directories, with all links and asset paths adjusted automatically.
This framework can automatically generate a complete threat model directly from IaC configurations. It automatically includes a set of default protocol styles from threatModel_Template/base_protocol_styles.md to ensure consistent visualization.
Here's how to use the Ansible plugin with a sample playbook:
-
Ensure you have the test playbook: The sample Ansible playbook is located at
tests/ansible_playbooks/simple_web_server/simple_web_server.yml. -
Run the analysis with the Ansible plugin:
python -m threat_analysis --ansible-path tests/ansible_playbooks/simple_web_server/simple_web_server.yml
This command will generate a complete threat model based on the Ansible playbook. The generated Markdown model will be saved in the
output/directory with a filename derived from your Ansible playbook (e.g.,simple_web_server.md).If you wish to specify a different output file for the generated model, you can use the
--model-fileoption:python -m threat_analysis --ansible-path tests/ansible_playbooks/simple_web_server/simple_web_server.yml --model-file my_generated_model.md
-
View the results in the generated
output/folder, which will now include elements from your Ansible configuration.
This framework can generate threats based on a list of Common Vulnerabilities and Exposures (CVEs) that you provide for specific components in your threat model.
To use this feature, you must first clone the CVE2CAPEC repository from GitHub next to the SecOpsTM project directory.
# In the same directory where you cloned SecOpsTM
git clone https://github.com/Galeax/CVE2CAPEC.gitThis will create a directory structure like this:
/your/development/folder/
├── SecOpsTM/
└── CVE2CAPEC/
The tool will then use the CVE2CAPEC database to map your specified CVEs to CAPEC attack patterns, which are then used to identify relevant MITRE ATT&CK techniques.
-
Create
cve_definitions.yml: By default, the tool looks forcve_definitions.ymlin the directory of the model or project. You can override this path using the--cve-definitions-filecommand-line argument. -
Define CVEs for your equipment: In this file, list the equipment (servers or actors from your threat model) and the CVEs associated with them.
Example
cve_definitions.yml:# The equipment name must match the name of a server or actor in your threat_model.md file. WebServer: - CVE-2021-44228 # Log4Shell - CVE-2023-1234 DatabaseServer: - CVE-2022-5678
-
Run the analysis: Run the analysis as usual. The tool will automatically detect the
cve_definitions.ymlfile, generate threats based on the CVEs, and include them in the report.python -m threat_analysis --model-file path/to/your_model.md
The new CVE-based threats will appear in the generated report, linked to the corresponding equipment.
For a more interactive experience, the framework provides a web-based UI that runs on a local server. This unified interface gives you access to two distinct modes from a central menu.
-
Launch the server:
python -m threat_analysis --server
The console will display the address (e.g.,
http://127.0.0.1:5000) to open in your web browser. -
Choose a Mode from the Menu:
- Simple Mode: An interface to load a Markdown file and see the generated diagram and analysis in real-time. Ideal for quick visualization and reporting on existing models.
- Graphical Editor: A full-featured, interactive canvas to build, modify, and analyze threat models from scratch directly in the browser. It includes a toolbar for adding elements, a properties panel for editing, and the ability to generate all artifacts without touching Markdown directly.
Note: When using
--server, the--model-fileoption can be used to load an initial threat model for the Simple Mode. The Graphical Editor starts with a new, empty model.