Python framework for threat modeling, shifting left for developers
Top 37.3% on sourcepulse
This Python framework automates threat modeling for developers, aiming to integrate security earlier in the software development lifecycle. It generates Data Flow Diagrams (DFDs), sequence diagrams, and threat reports from system architecture definitions, reducing manual effort and improving security posture.
How It Works
pytm models system components (Servers, Datastores, Actors, etc.) and their interactions (Dataflows) using a Python DSL. It then processes these definitions against a built-in or custom threats database. The condition
field in threats allows for sophisticated matching against model element attributes and relationships, enabling automated threat identification and risk assessment.
Quick Start & Requirements
plantuml.jar
.tm.py --dfd | dot -Tpng -o tm/dfd.png
or tm.py --report docs/basic_template.md | pandoc -f markdown -t html > tm/report.html
.export USE_DOCKER=true; make image
then make
.Highlighted Details
stale_days
argument to track model-code drift.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The threats.json
file contains strings that are evaluated using eval()
, posing a security risk if the file permissions are not managed correctly. The README mentions a pytmGPT
feature for model generation from prose, but no details or links are provided.
2 months ago
1 day