Threat Modeling as Code (Python)
A declarative threat-modeling library for Python. Express your system as components, trust boundaries, and data flows, then analyze it with the STRIDE methodology to get actionable, version-controlled mitigations.
Features
- Declarative
Model,Component,Boundary, andDataFlowtypes - STRIDE threat classification: Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege
- Trust-boundary-aware data flow analysis
- Built-in, context-aware mitigation catalog
- Zero runtime dependencies
- Type hints included (
py.typed)
Installation
pip install threat-modeling-py
Quick Start
from threat_modeling import Model, Component, Boundary
app = Model('payment-api')
app.add(Component('api', component_type='api', environment='k8s',
stores=['user-data'], exposed=True))
app.add(Boundary('internet', untrusted=True, trusts=['api']))
for threat in app.analyze():
print(threat.kind, threat.target)
for mitigation in threat.mitigations:
print(' -', mitigation)
Development
cd implementations/security/threat-modeling/python
pip install -e ".[dev]"
pytest test_threat_modeling.py -v
Publishing to PyPI
cd implementations/security/threat-modeling/python
python -m build
python -m twine check dist/*
python -m twine upload dist/*
License
MIT License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file threat_modeling_py-1.0.0.tar.gz.
File metadata
- Download URL: threat_modeling_py-1.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f04305589d2734e41b8fda66677cc3fb9cf797306f939dfe74ffcc635a407b
|
|
| MD5 |
2bc1b1633065cd3a408bb987b87ab980
|
|
| BLAKE2b-256 |
9e49bf27cacf43be7a7436208c8c5b612b50555a39ab5ac458fbdfb51b5ec021
|
File details
Details for the file threat_modeling_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: threat_modeling_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b573f0219c5863ec98a8c8e7a101e546fa744138db588fe116307d3463c862a
|
|
| MD5 |
802b23737a1eb2ab9216e4e13959c431
|
|
| BLAKE2b-256 |
b1b4f53801a84374f628ccdd0f0da59be18ffa57c4e45ea9b14fbcbfd0b94061
|