OWASP SecOpsTM
The purpose of SecOpsTM project is to make threat modeling an accessible, automated, and dynamic practice that can be integrated into modern DevSecOps workflows. It aims to bridge the gap between complex cybersecurity analysis and continuous software development.
Based on PyTM: This framework leverages PyTM’s modeling primitives and extends them with advanced reporting, MITRE mapping, and diagram generation.
Project Description
SecOpsTM is a Python-based framework for end-to-end threat modeling.
It automates STRIDE threat identification and maps them to MITRE ATT&CK.
Define your system using a simple Markdown DSL or import from IaC (Ansible).
The tool generates rich HTML reports, JSON data, and visual diagrams.
A powerful CLI enables seamless integration into CI/CD pipelines.
The interactive web GUI allows for real-time graphical model building.
Visualize your threat landscape with ATT&CK Navigator and Attack Flow diagrams.
It supports custom threat rules and configurable severity calculations.
Built on PyTM, it provides a highly extensible and developer-friendly platform.
This framework streamlines security analysis from design to deployment

Quick Start / Installation
- Clone the repository:
git clone https://github.com/ellipse2v/SecOpsTM.git cd SecOpsTM - Install Python dependencies:
pip install -e .This command installs all project dependencies and sets up the project in “editable” mode, which is recommended for development. For a standard installation (e.g., for deployment), you can use:
pip install .Note on Installation Modes:
pip install -e .: Installs the project in “editable” mode. This is recommended for development as any changes you make to the source code in your project directory are immediately reflected without needing to reinstall.pip install .: Performs a standard installation, copying the project files into your Python environment. Use this for deployment or when using the package as a dependency.
- Install Graphviz (for diagram generation):
- Windows: https://graphviz.org/download/
- macOS:
brew install graphviz - Linux:
sudo apt-get install graphviz
After installation, restart your terminal or IDE.
Features
- Markdown-based Threat Modeling: Use a simple DSL to describe your architecture and flows.
- Automated STRIDE Analysis: Detects threats for each element and flow.
- MITRE ATT&CK Mapping: Each threat is mapped to relevant MITRE tactics and techniques.
- Severity Calculation: Customizable scoring (base, target, protocol).
- Comprehensive Reporting:
- HTML report with integrated threat statistics, detailed threat information, STRIDE/MITRE mapping, and D3FEND mitigations.
- JSON export for integration or further analysis.
- Visual Diagrams:
- DOT, SVG, and HTML diagrams with threat highlights.
- Navigable Project Reports:
- Generate a unified, navigable HTML report for complex projects with multiple nested threat models.
- Diagrams are interactive, with hover effects (zoom, shadow) on clickable elements.
- Fully self-contained and works offline, with all necessary assets (like
svg-pan-zoom.js) included locally.
- Real-time Markdown Editing: Edit your threat model in Markdown with live diagram preview.
- Extensible: All mappings and calculations are modular and easy to override.
- PyTM Compatibility: Supports PyTM’s model structure and can be extended with PyTM’s features.
1. Command Line Interface (CLI) Mode
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:
python -m threat_analysis --model-file threatModel_Template/threat_model.md --navigator(You can omit
--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.python -m threat_analysis --model-file path/to/your_model.md --attack-flowThis will generate one
.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
2. Project Mode: Hierarchical Threat Models
The 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.
3. Infrastructure as Code (IaC) Integration (Ansible Example)
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.ymlThis 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.
4. CVE-Based Threat Generation (Optional)
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.
Prerequisites
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.git
This 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.
Usage
-
Create
cve_definitions.yml: In the root of theSecOpsTMproject, create a file namedcve_definitions.yml. -
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.mdThe new CVE-based threats will appear in the generated report, linked to the corresponding equipment.
Web-based Graphical User Interface (GUI) Mode (Optional)
Launch the interactive web editor to visualize your threat model in real-time, edit Markdown content, and export various formats directly from your browser.
Launch the GUI:
bash
python -m threat_analysis --gui
The console will display the address (e.g., http://127.0.0.1:5001) where you can access the GUI in your web browser.

Note: When using
--gui, the--model-fileoption can be used to load an initial threat model as a template into the editor. If not provided, the GUI will start with an an empty editor.
Threat Model DSL & Examples (threatModel_Template/threat_model.md)
This framework leverages PyTM’s modeling primitives. For a comprehensive reference of all available attributes and their usage, please refer to the PyTM Documentation. Note that this framework may extend PyTM with additional attributes or behaviors.
# Threat Model: Advanced DMZ Architecture
## Description
A network with a DMZ, external/internal firewalls, and a command zone. The goal is to identify STRIDE threats and map them to MITRE ATT&CK.
## Boundaries
- **Internet**: color=lightcoral
- **DMZ**: color=khaki
- **Intranet**: color=lightgreen
- **Command Zone**: color=lightsteelblue
## Actors
- **External Client 1**: boundary=Internet
- **Operator**: boundary=Command Zone
## Servers
- **External Firewall**: boundary=DMZ
- **Internal Firewall**: boundary=Intranet
- **Central Server**: boundary=Intranet
## Data
- **Web Traffic**: classification=public, lifetime=transient
## Dataflows
- **External Client to External Firewall**: from="External Client 1", to="External Firewall", protocol="HTTPS", data="Web Traffic", is_encrypted=True
## Severity Multipliers
- **Central Server**: 1.5
- **External Firewall**: 2.0
## Custom Mitre Mapping
- **Protocol Tampering**: tactics=["Impact", "Defense Evasion"], techniques=[{"id": "T1565", "name": "Data Manipulation"}]
Common Attributes
Several elements in the threat model DSL support common attributes to enhance their representation and behavior:
color: Specifies the color of the element in the generated diagrams.- Applies to: Boundaries, Actors, Dataflows, Protocol Styles.
- Values: Can be a standard HTML color name (e.g.,
red,blue,lightgray), or a hexadecimal color code (e.g.,#FF0000).
line_style: Defines the style of lines for dataflows or protocols in diagrams.- Applies to: Protocol Styles.
- Values:
solid,dashed,dotted.
is_trusted: Indicates whether a Boundary is considered trusted. This can influence threat analysis.- Applies to: Boundaries.
- Values:
TrueorFalse.
is_encrypted: Specifies whether a Dataflow is encrypted. This is crucial for information disclosure threat analysis.- Applies to: Dataflows.
- Values:
TrueorFalse.
Protocol Styles and Legends
To ensure that protocols are correctly styled in diagrams and appear in the legend, you must define them in the ## Protocol Styles section of your threat model. The system intentionally does not assign default colors to new protocols. This gives you full control over the final visualization.
How it works:
- Use a protocol in a
Dataflow, e.g.,protocol="NEW_PROTO". - Define its style under
## Protocol Stylesto make it appear in the legend: ```markdownProtocol Styles
- HTTPS: color=darkgreen, line_style=solid
- HTTP: color=red, line_style=solid
- NEW_PROTO: color=cyan, line_style=dotted ```
If you skip step 2, the protocol will be drawn in the diagram with a default style, but it will not be included in the legend.
Bidirectional Dataflow Visualization
This makes bidirectional communications visually clear and reduces clutter in your architecture diagrams.
Example:
If your model contains:
## Dataflows
- A to B: from="A", to="B", protocol="HTTPS"
- B to A: from="B", to="A", protocol="HTTPS"
The diagram will show:
A <--> B
(with a single arrow using dir="both" in DOT/Graphviz)
This feature is enabled by default and works for all protocols.
Report
After running the analysis, you will find a timestamped folder in output/ (e.g., output/example) containing:
stride_mitre_report.html:

mitre_analysis.json:{ "analysis_date": "2025-06-29T15:31:56.517773", "threats_detected": 183, "threat_types": [ "Threat", "Tampering", "Information Disclosure", "Elevation of Privilege", "Spoofing", "Denial of Service", "Repudiation" ], "mitre_mapping": { "Spoofing": { "tactics": [ "Initial Access", "Defense Evasion", "Credential Access" ], "techniques": [ { "id": "T1566", "name": "Phishing", "description": "Identity spoofing via phishing" } ] }, "Tampering": { "tactics": [ "Defense Evasion", "Impact", "Initial Access", "Execution" ], "techniques": [ { "id": "T1565", "name": "Data Manipulation", "description": "Unauthorized data modification" } ] } }, "detailed_threats": [ { "type": "Threat", "description": "Vulnerability in the management interface of External Firewall", "target": "External Firewall", "severity": {"score": 8.5, "level": "HIGH"}, "mitre_techniques": [{"id": "T1068", "name": "Exploitation for Privilege Escalation"}], "stride_category": "Elevation of Privilege" }, { "type": "Threat", "description": "Lateral movement from Central Server to other systems in the network", "target": "Central Server", "severity": {"score": 8.5, "level": "HIGH"}, "mitre_techniques": [{"id": "T1021", "name": "Remote Services"}], "stride_category": "Elevation of Privilege" }, { "type": "Threat", "description": "Insecure security configuration or hardening on App Server 1", "target": "App Server 1", "severity": {"score": 6.0, "level": "MEDIUM"}, "mitre_techniques": [{"id": "T1562", "name": "Impair Defenses"}], "stride_category": "Information Disclosure" }, { "type": "Threat", "description": "Data exfiltration or leakage from Application Database", "target": "Application Database", "severity": {"score": 8.5, "level": "HIGH"}, "mitre_techniques": [{"id": "T1041", "name": "Exfiltration Over C2 Channel"}], "stride_category": "Information Disclosure" } ] }tm_diagram__example.dot:
(Graphviz DOT format for architecture)-
tm_diagram__example.svg:
-
Project Structure Example:

- MITRE ATT&CK Navigator Integration:

Note: All screenshots and example files are located in the
output/example/directory for easy preview and documentation.
Roadmap
- Vulnerability Database Integration: Link ATT&CK techniques to CVEs for deeper context.
- Attack Path Simulation: Algorithms to identify and visualize potential attack paths.
- Expanded IaC Support: New plugins for Terraform and CloudFormation.
- ML-Enhanced Threat Identification: Using machine learning to predict new threats.
- Offline LLM Enhancement: Integrate a local LLM for advanced contextual threat analysis.
- Attack path generation: compatible with Attack Flow.
Tooling Scripts Documentation
This document provides an explanation for each of the Python scripts located in the tooling/ directory. These scripts are used for data acquisition, data processing, and quality assurance for the threat modeling framework.
build_stride_capec_mapping.py
- Purpose: Builds the
stride_to_capec.jsonfile, which maps STRIDE threat categories to specific CAPEC (Common Attack Pattern Enumeration and Classification) entries. - Process:
- Scrapes data from Markdown files on
ostering.com. - Applies manual corrections from a hardcoded
CORRECTIONSdictionary. - Enriches the data with supplemental mappings from a
SUPPLEMENTAL_MAPPINGSdictionary. - Writes the final data to
threat_analysis/external_data/stride_to_capec.json.
- Scrapes data from Markdown files on
- Usage: A data maintenance tool to be run when the source data changes or when manual corrections need to be updated.
capec_mitre_parser.py
- Purpose: A web scraper to parse and extract detailed information from the official CAPEC and MITRE ATT&CK websites.
- Functionality:
parse_capec_entry(capec_id): Fetches a specific CAPEC page and extracts details like title, description, severity, mitigations, etc.parse_mitre_attack_technique(technique_id): Fetches a specific MITRE ATT&CK technique page and extracts details like tactics, platforms, mitigations, etc.- Saves the aggregated results into a
capec_mitre_results.jsonfile.
- Usage: An ad-hoc tool for deep-diving into specific attack patterns or techniques for research purposes.
capec_to_mitre_builder.py
- Purpose: Creates the
capec_to_mitre_structured_mapping.jsonfile, which bridges CAPEC attack patterns and MITRE ATT&CK techniques. - Process:
- Downloads a ZIP file with CAPEC data in CSV format from the MITRE website.
- Parses the CSV to extract CAPEC ID, name, and linked ATT&CK techniques.
- Uses a web scraping fallback to fetch ATT&CK techniques from the CAPEC HTML page if they are missing in the CSV.
- Adds a few hardcoded manual mappings.
- Saves the structured JSON to
threat_analysis/external_data/capec_to_mitre_structured_mapping.json.
- Usage: A crucial data-building script that should be run periodically to keep the CAPEC to ATT&CK mapping up-to-date.
cis_controls_parser.py
- Purpose: Parses the official CIS Controls to MITRE ATT&CK mapping from an Excel file and converts it to a structured JSON file.
- Process:
- Reads the
CIS_Controls_v8_to_Enterprise_ATTCK_v82_Master_Mapping__5262021.xlsxfile. - Extracts the CIS Safeguard ID, title, and the corresponding MITRE ATT&CK Technique ID.
- Generates a documentation URL for each CIS control.
- Saves the data as
cis_to_mitre_mapping.jsoninthreat_analysis/external_data/.
- Reads the
- Usage: Generates a key data file for suggesting CIS Control mitigations. Run if the source Excel file is updated.
copy_cve_data.py
- Purpose: A utility to copy the CVE-to-CAPEC mapping database from an external repository into the project’s
external_datadirectory. - Process:
- Assumes the
CVE2CAPECrepository is cloned next to the project directory. - Copies the
databasedirectory fromCVE2CAPECtothreat_analysis/external_data/cve2capec.
- Assumes the
- Usage: Must be run by a developer after cloning the
CVE2CAPECrepository to enable the optional CVE-based threat generation feature.
download_attack_data.py
- Purpose: Downloads data from MITRE.
- Functionality: The active code is configured to download a CSV file from
capec.mitre.organd save it asCAPEC_VIEW_ATT&CK_Related_Patterns.csv. - Usage: A data acquisition script. (Note: There is a discrepancy between the script’s comments, which mention
enterprise-attack.json, and its active code).
download_nist_data.py
- Purpose: Downloads the official NIST 800-53 R5 to MITRE ATT&CK mapping file.
- Process:
- Downloads the
nist800-53-r5-mappings.xlsxfile from the “Center for Threat-Informed Defense” GitHub repository. - Saves the file to
threat_analysis/external_data/.
- Downloads the
- Usage: Acquires the necessary data file for providing NIST 800-53 control suggestions.
generate_attack_flow.py
- Purpose: A library of helper functions to programmatically generate
.afbfiles compatible with theattack-flowapplication. - Functionality: Provides functions like
create_action_object,create_asset_object, andcreate_connection_objectsto build the components of an attack flow diagram. - Usage: This script is a toolkit used by other parts of the application (like the
AttackFlowGeneratorclass) to construct attack flow diagrams. It does not perform any analysis itself.
validate_capec_json.py
- Purpose: Validates the local
stride_to_capec.jsonfile against the official MITRE CAPEC website to ensure descriptions are correct. - Process:
- Loads the local JSON file.
- For each entry, it scrapes the official CAPEC definition page on
capec.mitre.org. - It compares the local description with the official online description.
- It prints a summary report of any mismatches found.
- Usage: A quality assurance tool to be run after
build_stride_capec_mapping.pyto check for data drift or scraping errors.