ChrisAdkin8/tf-analyze

GitHub: ChrisAdkin8/tf-analyze

一款集静态分析与攻击路径图优先级排序于一体的 Terraform IaC 安全扫描工具,提供完整 HCL 修复建议并支持十种集成方式。

Stars: 1 | Forks: 0

tf-analyze

# tf-analyze [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/dbdb54f2d9110603.svg)](https://github.com/ChrisAdkin8/tf-analyze/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/ChrisAdkin8/tf-analyze?include_prereleases&sort=semver)](https://github.com/ChrisAdkin8/tf-analyze/releases) [![GitHub Marketplace](https://img.shields.io/badge/marketplace-tf--analyze-blue?logo=githubactions)](https://github.com/marketplace/actions/tf-analyze) [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/tfanalyze.tf-analyze?label=vs%20code%20marketplace&logo=visualstudiocode)](https://marketplace.visualstudio.com/items?itemName=tfanalyze.tf-analyze) [![Open VSX](https://img.shields.io/open-vsx/v/tfanalyze/tf-analyze?label=open%20vsx&logo=eclipseide)](https://open-vsx.org/extension/tfanalyze/tf-analyze) [![Docker](https://img.shields.io/badge/docker-ghcr.io-blue?logo=docker)](https://github.com/ChrisAdkin8/tf-analyze/pkgs/container/tf-analyze) ![Python ≥3.10](https://img.shields.io/badge/python-%E2%89%A53.10-blue) ![Rules: 232](https://img.shields.io/badge/rules-232-brightgreen) ![fix_hcl: 100%](https://img.shields.io/badge/fix__hcl-100%25-brightgreen) ![MITRE / CWE / D3FEND](https://img.shields.io/badge/MITRE%20%2F%20CWE%20%2F%20D3FEND-69%25%20%2F%2053%25%20%2F%2040%25-brightgreen) ![Tests: 654](https://img.shields.io/badge/tests-654%20passing-brightgreen) [![Rule docs](https://img.shields.io/badge/rule%20docs-232%20pages-brightgreen?logo=github)](https://chrisadkin8.github.io/tf-analyze/rules/) ![License: MPL-2.0](https://img.shields.io/badge/license-MPL--2.0-blue) **[快速入门](#quickstart) · [为什么选择 tf-analyze?](#why-tf-analyze) · [功能特性](#features) · [文档](#documentation) · [添加规则](#adding-a-rule) · [仓库布局](#repository-layout)** `tf-analyze` 可以作为 Claude Code 技能 (`/tf-analyze`) 运行,也可以作为独立的 Python CLI、GitHub Action、Docker 容器、pre-commit hook、LSP server、VS Code 扩展、HCP Terraform Run Task、任何 AI agent (Cursor, Claude Desktop, Continue.dev, …) 的 [MCP server](integrations/mcp-server/),以及作为 [原生 Terraform provider](terraform-provider/) (`data "tfanalyze_scan"`) 运行。同一套引擎,十种使用界面。 ## 快速入门 ### 1. Docker — 无需安装 Python ``` docker run --rm -v "$(pwd):/workspace" \ ghcr.io/chrisadkin8/tf-analyze \ --target /workspace --format html > report.html open report.html ``` ### 2. 从源码运行 (Python ≥ 3.10) ``` git clone https://github.com/ChrisAdkin8/tf-analyze.git cd tf-analyze ./install.sh # installs as a Claude Code skill pip install python-hcl2 # optional fast-path (default-on if present) python3 scripts/detect.py --target /path/to/terraform python3 scripts/detect.py --target . --mode diff --fail-on HIGH --format sarif > out.sarif python3 scripts/detect.py --list-rules python3 scripts/detect.py --explain SEC-AWS-IAM-POLICY-005 ``` ### 3. 在 Claude Code 内部 ``` /tf-analyze # full audit, all areas /tf-analyze focus:security mode:diff # PR review /tf-analyze mode:verify-fixed # confirm prior fixes ``` ### 4. VS Code 扩展 实时诊断、Quick Fix、攻击图、Module Reuse Advisor 以及 `vscode://` URI 处理器 —— 全部包含在一个独立的 `.vsix` 中(引擎和规则目录已捆绑;无需克隆辅助仓库)。 ``` # Marketplace (首选,在列表上线后) code --install-extension tfanalyze.tf-analyze # 或者从下载的 .vsix (在 Marketplace 列表发布前的当前方法) code --install-extension tf-analyze-0.1.39.vsix ``` 打开任意 Terraform 工作区,六个状态栏快捷方式将出现在左下角: ``` 🛡 tf-analyze: 82 (B) · 7 findings 🛤 Attack Graph 🔀 Delta ✅ Compliance 🪄 Remediate 📦 Module Reuse ``` 要查看更深层面板针对丰富输入的渲染效果,请打开 [`examples/`](examples/) 中的展示语料库 —— `examples/module-reuse-demo/` (📦) 或 `examples/attack-graph-demo/` (🛤)。完整参考:[`docs/vscode-extension.md`](docs/vscode-extension.md)。 ### 5. GitHub Action ``` - uses: ChrisAdkin8/tf-analyze@v1 with: fail-on: HIGH post-pr-comment: true # inline `suggestion` blocks on every PR compliance-framework: owasp_iac # optional — adds a collapsible compliance gap report attack-graph: true # optional — embeds Mermaid attack graph in PR summary ref: v0.2.1 # optional — pin the engine version (default: main) ``` 有关包含 SARIF 上传、引擎渲染的 PR 摘要 (R28.1) 和 HTML 产物的完整工作流,请参见 [`integrations/github-action.yml`](integrations/github-action.yml)。 ## 为什么选择 tf-analyze? 扫描器的优劣取决于它所能促发的行动。当同类工具停留在“这是一个发现”时,`tf-analyze` 已经通过攻击路径中心性对发现进行排名,提供 HCL 修复,并在悬停时展示对抗场景。 | | tf-analyze | tfsec | checkov | Prowler | |---|---|---|---|---| | 静态 HCL 分析 | ✅ | ✅ | ✅ | ❌ (实时) | | 计划阶段 (`terraform show -json`) 分析 | ✅ | ⚠️ 部分 | ✅ | ❌ | | 内置攻击路径图 | ✅ | ❌ | ❌ | ❌ | | 带有节省行数 ROI 的 Module Reuse Advisor | ✅ | ❌ | ❌ | ❌ | | 综合风险评分 + 字母评级 (A–F) | ✅ | ❌ | ❌ | ❌ | | **每条**规则都提供 `fix_hcl` 片段 | ✅ (100%) | ⚠️ 部分 | ⚠️ 部分 | 不适用 | | 内联 GitHub PR `suggestion` 块 | ✅ | ❌ | ❌ | 不适用 | | MITRE ATT&CK 映射 (技术 + 战术分组输出) | ✅ 绑定到 v17 | ❌ | ⚠️ 部分 | ⚠️ 通过插件 | | MITRE D3FEND 防御技术标签 | ✅ | ❌ | ❌ | ❌ | | SARIF 输出中的 CWE 分类 | ✅ | ❌ | ⚠️ 部分 | ❌ | | OSCAL Assessment Results JSON 输出 | ✅ | ❌ | ❌ | ❌ | | OWASP IaC Cheat Sheet 合规性映射 | ✅ | ❌ | ❌ | ❌ | | 基线棘轮 (`--baseline prior.json`) | ✅ | ⚠️ 通过过滤器 | ✅ | ❌ | | 用于 IDE 诊断的 LSP server | ✅ | ❌ | ❌ | ❌ | | HCP Terraform Run Task 集成 | ✅ | ❌ | ❌ | ❌ | | 原生 Terraform provider (`data "tfanalyze_scan"`) | ✅ | ❌ | ❌ | ❌ | | 用于 AI agent 的 MCP server (Cursor / Claude Desktop / …) | ✅ | ❌ | ❌ | ❌ | | YAML 自定义规则 | ✅ | ✅ (Rego) | ✅ (Python+YAML) | ✅ (Python) | | 仅标准库核心 (可选快速路径) | ✅ | 不适用 | ❌ (pip) | ❌ (pip) | ### tf-analyze 的不同之处 1. **攻击路径图 + 修复中心性** —— 从互联网可达资源到核心资产进行 BFS。关键路径上的发现会被提升一个紧急级别;修复方案根据其能解锁多少核心资产进行排名。 2. **每条规则都提供带有破坏性分类的 `fix_hcl`** —— 每个发现都附带一个 HCL 片段以及 `Non-disruptive` / `Plan required` / `Forces replacement` 标签,因此审查者可以在应用前看到操作影响。 3. **对抗场景叙述** —— HIGH/CRITICAL 级别的发现附带 3-4 句话的违规故事(如 Capital One、Accenture、SolarWinds),以将严重性植根于真实结果中。 4. **IAM 策略分析 (HCL + 内联 JSON)** —— 十条专用规则同时遍历 `data "aws_iam_policy_document"` 块和 `aws_iam_policy` / `aws_iam_role_policy` 上的 `policy = jsonencode({...})` 字符串。涵盖通配符操作、通配符资源、公共主体、`iam:*` 提权、完全管理员权限和 NotAction。 5. **基线棘轮** —— 通过快照当前的发现,在嘈杂的遗留仓库中采用此工具;此后只有回归问题会阻止 CI。 6. **Kubernetes + Helm 覆盖** —— `kubernetes_namespace` Pod Security Admission、缺失的 `kubernetes_network_policy`、`cluster-admin` `RoleBinding`,以及 `helm_release` 覆盖如 `service.type=LoadBalancer` 和 `securityContext.privileged=true`。 7. **感知 Provider 版本** —— 规则可以声明 `applies_when: { min_provider: { aws: "5.0" } }`,以便在较旧的 provider 版本上自动跳过,而不是产生误报。 ## 功能特性 ### 检测 六个系列共 217 条规则。使用 `--list-rules` 枚举它们;使用 `--explain RULE-ID` 完整打印单条规则。 | 系列 | 前缀 | 焦点 | |--------|--------|-------| | Security | `SEC-*` | IAM 过度授权、公共暴露、硬编码机密、加密缺失、暴露端口、MFA、密钥轮换 | | Robustness | `ROB-*` | 缺少 `prevent_destroy`、无状态锁定、未版本化的 provider、缺少备份 | | Stack | `STK-*` | GKE/EKS/AKS 加固、RDS/CloudSQL 配置、Lambda DLQ/追踪、KMS 轮换 | | Ops & Governance | `OPS-*`, `MOD-*`, `COST-*` | 标签/标记、未固定的模块、供应链引用、成本控制 | | Cross-resource | `INT-*`, `graph_check` | 意图-实现差距、KMS 位置一致性、IAM 广度 | | Module reuse (advisory) | `MOD-REUSE-*` | 模仿流行 Terraform Registry 模块的手工脚手架 —— INFO 级别,从不阻断 CI。传递 `--show-info` 进行渲染 | **按云平台分布:** AWS 86 · GCP 43 · Azure 34 · Kubernetes/Helm 5 · 跨云 49。 ### 执行模式 | 模式 | 用例 | |------|----------| | `static` (默认) | 完整源码扫描 —— 无需凭证 | | `diff` | 仅变更文件,自动检测基础分支 —— 适用于 PR CI | | `plan` | 静态扫描 + 来自 `terraform show -json` 的解析值 | | `fleet` | 多仓库扫描;展现组织范围内的模式 | | `trend` | 遍历 git 历史;显示每次提交的新增/解决/净变化 | | `pr-review` | 通过一键 `suggestion` 块发布内联 GitHub PR 审查评论 | ### 输出格式 | `--format` | 输出内容 | |------------|-------------| | `text` (默认) | 单行分数头 + 发现列表 + 攻击图 mermaid | | `json` | 顶层 `summary` 块 + 发现;供 `--compare`、`--baseline` 使用 | | `sarif` | SARIF v2.1.0 —— GitHub Code Scanning 上的行级注释 | | `html` | 独立报告,包含分数横幅、紧急标签、攻击图 SVG | | `compliance` | CIS / PCI-DSS / SOC 2 / OWASP IaC 每个控制项的 PASS/FAIL (`--compliance-framework `;`--oscal PATH` 用于 OSCAL JSON)。`owasp_iac` 框架映射了 [OWASP IaC Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Infrastructure_as_Code_Security_Cheat_Sheet.html) 中可静态分析的项目。 | | `mitre` | 按 MITRE ATT&CK 技术分组的发现 | | `pr-summary` | 适用于 PR 描述 / PR-bot 评论的 GitHub 风味 Markdown 格式 —— 分数横幅、前 3 个发现表格(链接到文档站点)、首要修复、可折叠的 Mermaid 攻击图 | ### 风险评分 每次 text、JSON 和 HTML 扫描都会发出一个确定性的 0-100 健康分数和 A/B/B-/C/D/F 字母评级。该分数与 SKILL.md 中描述的数字相同 —— `scripts/detect.py` 中的 `_RISK_WEIGHTS` 和 `_GRADE_TIERS` 是唯一的真实来源。 ``` # tf-analyze: 82 (B) · 0 CRITICAL · 0 HIGH · 4 MEDIUM · 6 LOW · 0 INFO ``` ``` "summary": { "scoring_version": 1, "score": 82, "grade": "B", "counts": {"CRITICAL": 0, "HIGH": 0, "MEDIUM": 4, "LOW": 6, "INFO": 0}, "suppressed_count": 0, "formula": "max(0, 100 - sum(weight * count)); weights: CRITICAL=15, HIGH=7, MEDIUM=3, LOW=1, INFO=0; suppressed at half weight" } ``` 已抑制和基线抑制的发现按半权重计算(已确认,但潜在风险仍然存在)。INFO 发现的权重为 0。`scoring_version` 字段固定了公式 —— 权重的变化会增加其版本号,以便下游门禁可以检测到重大变更。CI 门禁使用 `--fail-on LEVEL`(紧急层级)而不是基于评级门禁,这是有意为之 —— 评级用于趋势可见性,而非通过/失败判定。 ### 常用修饰符 | 标志 | 效果 | |------|--------| | `--fail-on LEVEL` | 如果存在任何 LEVEL 或以上级别的发现,则以退出码 1 退出 (CI 门禁) | | `--baseline prior.json` | 针对快照进行棘轮比较 —— 仅 NEW 发现会影响退出码 | | `--attack-graph` | 构建 互联网 → 核心资产 图;提升关键上的发现 | | `--show-fixes` | 渲染带有破坏性标签的 `fix_hcl` 内联内容 | | `--gen-tests OUTDIR` | 生成原生的 `.tftest.hcl` 断言文件 | | `--apply-fixes dry-run\|apply` | 预览 / 将 `fix_hcl` 补丁写入源文件 | | `--cache` | 基于文件 + 目录哈希的增量扫描缓存 | | `--diff-base REF` | 限制为自 `REF` 以来更改的 `.tf` 文件 | | `--no-hcl2` | 禁用 python-hcl2 快速路径 (环境变量: `TF_ANALYZE_NO_HCL2=1`) | | `--show-info` | 渲染 INFO 层级的发现(例如 `MOD-REUSE-*` 模块重用建议)。默认关闭 —— INFO 计入 `summary.counts.INFO` 但不显示 | 完整 CLI 参考:[`docs/cli.md`](docs/cli.md)。 ### 集成 | | 路径 | 文档 | |---|------|-----| | GitHub Action | [`integrations/github-action.yml`](integrations/github-action.yml) | SARIF + 内联 PR `suggestion` 块 + 引擎渲染的 PR 摘要 (`--format pr-summary`);可选的 `compliance-framework` / `attack-graph` / `show-info` 输入;通过 `ref` 固定以实现可重现的 CI | | VS Code 扩展 (v0.1.39) | [`vscode-extension/`](vscode-extension/) | [`docs/vscode-extension.md`](docs/vscode-extension.md) —— 独立的 `.vsix`(捆绑其自身的引擎),LSP 驱动的实时诊断、Quick Fix、带有攻击图 / 差异 / 合规性 / 修复 / 模块重用快捷方式的状态栏分数+评级徽章 (`82 (B) · 7 findings`),带有差异预览的批量 apply-fixes、基线抑制 UI、MITRE ATT&CK 视图、规则解释器 + 4 动词 `vscode://` 深度链接处理器 (`/rule`, `/scan`, `/explain`, `/suppress`) | | 分数徽章服务 | [`integrations/badge-service/`](integrations/badge-service/) | FastAPI 应用 —— 每个仓库可嵌入的 SVG 分数徽章 (`https:///score//.svg`);HMAC 签名的 `/ingest` 端点接受 `detect.py --format json` 输出。工程完成;等待 `flyctl deploy`。 | | LSP server (`--lsp`) | `scripts/detect.py --lsp` | [`docs/lsp.md`](docs/lsp.md) | | Docker 镜像 | `ghcr.io/chrisadkin8/tf-analyze` | 多架构 `linux/amd64` + `linux/arm64`;捆绑 `python-hcl2` | | Web 演示 | [`demo/`](demo/) | FastAPI + CodeMirror 6 + d3 攻击图 | | Pre-commit hook | [`.pre-commit-hooks.yaml`](.pre-commit-hooks.yaml) | [`docs/pre-commit.md`](docs/pre-commit.md) | | HCP Terraform Run Task | [`integrations/run-task/`](integrations/run-task/) | [`docs/run-task.md`](docs/run-task.md) | | MCP server (Cursor / Claude Desktop / Continue / …) | [`integrations/mcp-server/`](integrations/mcp-server/) | FastMCP 包装器 —— `scan_workspace`、`explain_rule`、`apply_fixes`、`attack_graph`、`compliance_report` 工具 + `tfanalyze://catalogue` 资源。stdio 传输。针对 agent 端滥用进行了加固:`TFA_REPO_ROOT` 包含限制、每个工具上的 `` 信封、发现/字节截断上限。参见 [`integrations/mcp-server/README.md#hardening`](integrations/mcp-server/README.md#hardening)。 | | Terraform provider | [`terraform-provider/`](terraform-provider/) | `data "tfanalyze_scan"` 数据源 —— 通过 `precondition` 块在干净的扫描结果上限定 `terraform plan`/`apply`,无需外部 CI。 | ## 截图
Findings tab
Findings tab — urgency-badged, collapsible, with adversarial narrative + suggested fix
Attack Graph tab
Attack Graph — interactive force-directed SVG; critical path in red, crown jewels gold-bordered
Executive View tab
Executive View — findings reorganised into Entry Points / Lateral Movement / Crown Jewels / Blind Spots
Fix Priority tab
Fix Priority — findings ranked by attack-path centrality; CRITICAL-PATH and INET-REACHABLE badges
更多截图:[合规性报告](docs/images/compliance-report.png) · [修复破坏性标签](docs/images/fix-disruption.png) · [发现叙述面板](docs/images/findings-narrative.png)。 ## 文档 | 主题 | 文档 | |-------|-----| | 完整 CLI 参考 (自动生成) | [`docs/cli.md`](docs/cli.md) | | 编写自定义 `CUSTOM-*` 规则 | [`docs/custom-rules.md`](docs/custom-rules.md) | | LSP server (Neovim, Emacs, Zed, coc.nvim) | [`docs/lsp.md`](docs/lsp.md) | | HCP Terraform Run Task | [`docs/run-task.md`](docs/run-task.md) | | Pre-commit hook | [`docs/pre-commit.md`](docs/pre-commit.md) | | VS Code 扩展 | [`docs/vscode-extension.md`](docs/vscode-extension.md) | | 严重性校准方法 | [`docs/severity-calibration.md`](docs/severity-calibration.md) | | 目录规则 schema | [`catalog/README.md`](catalog/README.md) | | 针对 terragoat 的示例报告 | [`reports/README.md`](reports/README.md) | | 技能说明文本 (面向 LLM 的指令) | [`SKILL.md`](SKILL.md) | | 路线图和待办事项 | [`TODO.md`](TODO.md) | | 更新日志 | [`CHANGELOG.md`](CHANGELOG.md) | | 博客 (设计笔记、调试之旅、回顾) | [`docs/blog/`](docs/blog/) | 当此仓库通过 GitHub Pages 提供服务时 (`Settings → Pages → Deploy from branch: main / docs`),相同的内容可以在 `https://chrisadkin8.github.io/tf-analyze/` 访问,博客位于 `/blog/`。 ## 添加规则 ``` python3 scripts/detect.py --new-rule SEC-MYDOMAIN-001 # 已写入 catalog/SEC-MYDOMAIN-001.yaml # 已写入 fixtures/sec_mydomain_001/main.tf ``` 编辑两个脚手架文件(贯穿 TODO 标记),然后运行: ``` python3 -m pytest tests/test_fixtures.py -k sec_mydomain_001 python3 scripts/detect.py --explain SEC-MYDOMAIN-001 python3 scripts/detect.py --strict-catalog --target /tmp # validates schema ``` 目录 schema:[`catalog/README.md`](catalog/README.md)。自定义规则演练:[`docs/custom-rules.md`](docs/custom-rules.md)。 ## 演示语料库 — `examples/` 三个语料库,既充当引擎冒烟测试,又作为对跨多个资源进行图推理的界面的端到端演示。选择器详见 [`examples/README.md`](examples/README.md)。 | 语料库 | 用途 | |---|---| | [`examples/terragoat/`](examples/terragoat/) | 基于 Bridgecrew 的 [terragoat](https://github.com/bridgecrewio/terragoat) 模型的三云有意含漏洞语料库。触发 SEC / ROB / STK / OPS / COST 领域的约 295 个发现。覆盖面最广;适合首次使用的用户。 | | [`examples/module-reuse-demo/`](examples/module-reuse-demo/) | 跨 AWS / GCP / Azure 的五个手工构建的 VPC/网络/AKS 集群,匹配流行的社区模块 + 两个反例。端到端演练 **📦 Module Reuse** 面板,显示所有三个置信度徽章层级。 | | [`examples/attack-graph-demo/`](examples/attack-graph-demo/) | 多层 AWS 应用:ALB → 公共 EC2 → 过于宽泛的 IAM role → S3 / Secrets / RDS。19 个节点,13 条边,6 个互联网可达,3 个核心资产。演练 **🛤 Attack Graph** 面板和 d3 演示。 | ``` python3 scripts/detect.py --target examples/terragoat --format html > demo.html ``` [`fixtures/`](fixtures/) 下的单规则固件(218 个正向 + 140 个纯净)是对这些语料库的补充 —— 它们各自隔离一条规则,因此自测失败能准确指出是哪个检测器坏了。演示语料库的偏移由 [`tests/test_examples_demos.py`](tests/test_examples_demos.py) 进行门禁检查,因此当目录更改改变了已记录的发现数量时,会导致本地 pytest 运行失败,而不是静默破坏 README 中的截图。 ## 仓库布局 ``` . ├── SKILL.md # Skill prose loaded as /tf-analyze in Claude Code ├── README.md # This file ├── CHANGELOG.md # Per-round release notes ├── TODO.md # Roadmap and backlog ├── CONTRIBUTING.md ├── LICENSE # MPL-2.0 ├── Dockerfile # ghcr.io/chrisadkin8/tf-analyze ├── pyproject.toml ├── install.sh # Symlinks repo into ~/.claude/skills/tf-analyze ├── .pre-commit-hooks.yaml # pre-commit.com hook declaration ├── .github/workflows/ # CI (ci.yml, docker.yml) ├── catalog/ # 217 rule definitions (one YAML per rule) │ └── README.md # Schema reference ├── fixtures/ # 218 positive + 140 clean (negative) fixtures ├── examples/ # Showcase corpora │ ├── terragoat/ # • Multi-cloud deliberately-vulnerable corpus │ ├── module-reuse-demo/ # • Module Reuse Advisor showcase (3 clouds) │ └── attack-graph-demo/ # • Multi-tier AWS app for the Attack Graph ├── scripts/ │ ├── detect.py # Detection engine (~7,800 LoC; optional python-hcl2) │ ├── self_test.py # Walks fixtures/ vs catalog/, asserts expected IDs │ ├── test_schema.py # Catalogue schema regression tests │ ├── stub-status.py # Reports stale `status: stub` entries │ ├── gen-cli-docs.py # Regenerates docs/cli.md from argparse │ ├── gen_clean_fixtures.py # Auto-scaffolds clean fixtures from fix_hcl │ └── apply_mitre.py # Idempotent MITRE ATT&CK mapper ├── tests/ # pytest suite (364 tests) ├── docs/ # User-facing documentation ├── integrations/ │ ├── github-action.yml │ ├── pre-commit-hook.yaml │ └── run-task/ # HCP Terraform Run Task FastAPI server + Dockerfile ├── vscode-extension/ # TypeScript extension (Quick Fix, attack-graph webview) ├── demo/ # FastAPI + d3 web demo (deployable to Fly.io) ├── reports/ # Example report outputs (delta-tracking demos) └── assets/ # Banner, icon ``` 技能文件 (`SKILL.md`, `catalog/`, `scripts/`, `fixtures/`, `integrations/`) 位于仓库根目录,因此 `./install.sh` 可以将整个目录 `ln -s` 到 `~/.claude/skills/tf-analyze` —— 无需嵌套的 `skill/` 子目录。 ## 贡献与维护 欢迎贡献 —— 工作流程详见 [`CONTRIBUTING.md`](CONTRIBUTING.md)。 日常维护命令: ``` python3 -m pytest tests/ # Full suite (~45s) python3 scripts/test_schema.py # Catalogue schema regression python3 scripts/stub-status.py --age 90d # Find stale stubs python3 scripts/gen-cli-docs.py # Regenerate docs/cli.md after argparse changes python3 scripts/gen_clean_fixtures.py --write # Auto-scaffold clean fixtures from fix_hcl python3 scripts/gen_sample_reports.py # Regenerate reports/*.{md,json} from terragoat ``` CI 门禁 (`.github/workflows/ci.yml`) 运行 pytest 套件、schema 验证器、CLI 文档新鲜度检查以及 `stub-status.py --age 180d`。Docker 镜像在标签推送时通过 `.github/workflows/docker.yml` 构建并发布。 ## 出处 在 HCP Vault + Consul + GKE 平台工程项目中构建并演练;许多目录规则可追溯到该基础设施的真实审计发现。该技能在设计上与提供商无关,可跨 AWS (86 条规则)、GCP (43 条规则)、Azure (34 条规则)、Kubernetes/Helm (5 条规则) 以及 49 条跨云规则运行 —— 总计 217 条活跃规则。在 GCP 上实现了完整的 CIS Foundations Benchmark 覆盖;在 AWS 和 Azure 上的对等性也在不断增加。合规性输出涵盖 CIS、PCI-DSS v4.0、SOC 2 Trust Services Criteria 以及 [OWASP IaC Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Infrastructure_as_Code_Security_Cheat_Sheet.html)。 ## 许可证 [Mozilla Public License 2.0](LICENSE)。目录规则和固件在同一许可证下发布,以允许上游贡献和下游分支。
标签:ATT&CK映射, CISA项目, D3FEND, DevSecOps, Docker, ECS, fix_hcl, GitHub Actions, HCL2, IaC安全, PR修复建议, Python, StruQ, Terraform, 上游代理, 云安全监控, 代码安全, 威胁建模, 安全扫描, 安全防御评估, 开源安全工具, 攻击图, 无后门, 时序注入, 模块化设计, 漏洞枚举, 自动化修复, 自动笔记, 请求拦截, 逆向工具, 逆向工程平台, 速率限制处理, 静态分析