Alpha_h4ck
- 关注
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
关于hcltm
目前,社区中有多种方法可以记录威胁模型,从简单的文本文件,到更深入一点的Word文档,再到全面的威胁模型检测/构建集中解决方案。其中,威胁模型最有价值的两个属性是能够清楚地记录威胁,并能够驱动更深层次的分析。
hcltm旨在提供一个DevOps优先的方法来记录一个系统威胁模型,工具的主要针对的目标如下:
1、简单的文本文件格式
2、命令行驱动式的用户体验
3、整合版本控制系统(VCS)
该项目的hcltm规范基于HashiCorp的配置语言HCL2,其目的是“让人易于阅读和编写,并且是一种基于JSON的变体,更易于机器生成和解析”。结合hcltm cli软件和hcltm规范,安全研究人员可以在HCL中定义系统威胁模型,例如:
threatmodel "Tower of London" { description = "A historic castle" author = "@xntrik" attributes { new_initiative = "true" internet_facing = "true" initiative_size = "Small" } information_asset "crown jewels" { description = "including the imperial state crown" information_classification = "Confidential" } usecase { description = "The Queen can fetch the crown" } third_party_dependency "community watch" { description = "The community watch helps guard the premise" uptime_dependency = "degraded" } threat { description = "Someone who isn't the Queen steals the crown" impacts = ["Confidentiality"] control = "Lots of guards" } data_flow_diagram { // ... see below for more information } }
关于规范的完整描述,可以点击【这里】或运行下列命令查看。
hcltm generate boilerplate
hcltm命令行接口工具
安装
广大研究人员可以直接访问该项目的【Releases页面】下载该工具的最新版本,并将hcltm代码拷贝到我们的目录路径下。
使用Homebrew安装
brew install xntrik/repo/hcltm
使用Docker运行
docker run --rm -it xntrik/hcltm
使用GitHub Actions运行
hcltm可以使用【GitHubActions】整合进GitHub代码库中,这也是一种管理威胁模型的理想方式,而且也可以有助于将其整合进版本控制系统中。
源码构建
首先,我们需要使用下列命令将该项目源码克隆至本地:
git clone https://github.com/xntrik/hcltm.git
接下来,切换到项目目录中
cd hcltm
并运行下列命令完成工具代码构建:
make bootstrap make dev
工具使用
使用“-h”命令即可查看该工具支持的参数选项或子命令:
$ hcltm Usage: hcltm [--version] [--help] <command> [<args>] Available commands are: dashboard 基于现有的HCL威胁模型文件生成Markdown文件 dfd 基于现有的HCL威胁模型文件生成数据流图表PNG文件 generate 生成一个HCL威胁模型 list 枚举HCL文件中的威胁模型 validate 验证现有的HCL威胁模型文件 view 查看现有的HCL威胁模型文件
配置文件
initiative_sizes = ["S", "M", "L"] default_initiative_size = "M" info_classifications = ["1", "2"] default_info_classification = "1" impact_types = ["big", "small"] strides = ["S", "T"] uptime_dep_classifications = ["N", "D"] default_uptime_dep_classification = "N"
工具使用
枚举和查看威胁模型
$ hcltm list examples/* # File Threatmodel Author 1 examples/tm1.hcl Tower of London @xntrik 2 examples/tm1.hcl Fort Knox @xntrik 3 examples/tm2.hcl Modelly model @xntrik
验证威胁模型
$ hcltm validate examples/* Validated 3 threatmodels in 3 files
生成威胁模型
hcltm generate interactive
生成成交互式编辑器
hcltm generate interactive editor
仪表盘
$ hcltm dashboard -overwrite -outdir=dashboard-example examples/* Created the 'dashboard-example' directory Writing dashboard markdown files to 'dashboard-example' and overwriting existing files Successfully wrote to 'dashboard-example/tm1-toweroflondon.md' Successfully wrote to 'dashboard-example/tm1-fortknox.md' Successfully wrote to 'dashboard-example/tm2-modellymodel.png' Successfully wrote to 'dashboard-example/tm2-modellymodel.md' Successfully wrote to 'dashboard-example/dashboard.md'
工具使用截图
许可证协议
本项目的开发与发布遵循MIT开源许可证协议。
项目地址
hcltm:【GitHub传送门】
参考资料
https://owasp.org/www-community/Threat_Modeling
https://github.com/xntrik/hcltm/blob/main/spec.hcl
https://github.com/hashicorp/hcl/tree/hcl2
https://github.com/xntrik/hcltm#data-flow-diagram
https://owasp.org/www-project-proactive-controls/
https://d1.awsstatic.com/whitepapers/Security/AWS_Security_Checklist.pdf
https://community.marqeta.com/t5/engineering-blogs/threat-models-at-the-speed-of-devops/ba-p/40
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)