威胁建模工具
项目描述
threat-modeling
注意: 这是一个处于alpha阶段的实验性工具,正在积极开发中,API和YAML规范格式可能会更改。
这是一个受相关项目(如pytm)启发的Python威胁建模工具库。可以使用系统架构的YAML规范生成数据流图(DFD)。如果在YAML规范中包含威胁及其父子关系,还可以生成攻击树。
此YAML文档可以存储在版本控制中,并更新以跟踪DFD结构、已考虑的威胁列表、其缓解状态以及已应用的补偿性安全控制措施。
此外,此库将对策视为一等对象,除了威胁和DFD元素之外。这样做是为了更容易跟踪 为什么 实施了/应用了对策,并在决定实施各种建议的对策时提供帮助。
还有一个 threatmodel --check
选项,实际上是一个代码检查器,可以在CI/CD管道中运行(请参阅examples
中的CircleCI作业和下面的代码检查器部分)以标记问题。
安装
pip install --editable .
CLI使用
$ threatmodel --help
usage: threatmodel [-h] [--check] [--attack-trees] [--dfd]
[--generate-threats]
input
positional arguments:
input system specification (yaml)
optional arguments:
-h, --help show this help message and exit
--check lint/check your threat model definition
--attack-trees generate attack trees
--dfd generate data flow diagram
--generate-threats generate threats
代码检查器
threatmodel --check
将查找以下内容
- (代码检查器失败) 未分类的威胁(即具有未管理状态)
- (代码检查器失败) 对不存在子威胁的引用
- (代码检查器失败) 对不存在缓解措施的引用
数据流图
基于YAML的系统规范
以下YAML是一个示例规范(示例来自这篇论文(PDF))
---
name: Minesweeper
description: Minesweeper threat model
nodes:
- name: Settings File
type: Datastore
id: DFD1
- name: Game File
type: Datastore
id: DFD2
- name: DirectX API
type: ExternalEntity
id: DFD3
- name: user
type: ExternalEntity
id: DFD4
- name: Game Application
type: Process
id: DFD5
boundaries:
- name: System
members:
- DFD1
- DFD2
- DFD3
- DFD5
dataflows:
- name: Settings
first_node: DFD1
second_node: DFD5
bidirectional: True
- name: Game Data
first_node: DFD2
second_node: DFD5
bidirectional: True
- name: Graphics Rendering
first_node: DFD3
second_node: DFD5
- name: User Input
first_node: DFD4
second_node: DFD5
您可以使用如下方式
$ threatmodel --dfd minesweeper.yaml
[*] DFD saved in dfd.png
这将生成以下数据流图
威胁
您可以将威胁键添加到系统的YAML中,以加载系统的现有威胁,例如
threats:
- id: THREAT1
name: Attacker tampers with config file
description: An attacker is able to introduce malicious changes into the settings file
status: Unmanaged
base_impact: Medium
base_exploitability: Medium
dfd_element: DFD1
threat_category: Tampering
mitigations:
- MITIG1
威胁允许的键
name
(必需)id
(可选)description
(可选)status
(可选,缺失时默认为未管理)base_impact
(可选)base_exploitability
(可选)dfd_element
(可选)threat_category
(可选,缺失时默认为未知)child_threats
(可选,攻击者可能尝试的下一个威胁ID列表)mitigations
(可选,应用于此威胁的缓解ID列表)
威胁生成
为了生成用于后续分析的占位威胁
$ threatmodel --generate-threats examples/minesweeper.yaml
[⏳] Loading threat model, standby!
[🔪] New threats found! Saved in examples/minesweeper_generated.yaml.
缓解措施
您可以将缓解措施键添加到版本控制中,以存储已应用的缓解措施信息
mitigations:
- id: MITIG1
name: Restrictive permissions on configuration file.
description: Prevents unauthorized users from writing changes to the Minesweeper configuration file.
缓解措施允许的键
name
(必需)id
(可选)description
(可选)
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
threat_modeling-0.0.1.tar.gz (20.9 KB 查看散列)
构建分布
threat_modeling-0.0.1-py3-none-any.whl (37.2 KB 查看散列)