cognis-digital/tfscan

GitHub: cognis-digital/tfscan

一款用于扫描 Terraform 计划与配置文件以发现基础设施即代码中配置错误的静态分析工具。

Stars: 0 | Forks: 0

TFSCAN # TFSCAN ### 扫描 Terraform 计划/配置以发现配置错误 [![PyPI](https://img.shields.io/pypi/v/cognis-tfscan.svg?color=6b46c1)](https://pypi.org/project/cognis-tfscan/) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/b640acca56055521.svg)](https://github.com/cognis-digital/tfscan/actions) [![License: COCL 1.0](https://img.shields.io/badge/License-COCL%201.0-2b6cb0.svg)](LICENSE) [![Suite](https://img.shields.io/badge/Cognis-Neural%20Suite-6b46c1.svg)](https://github.com/cognis-digital) *Cognis Neural Suite 的一部分。*
``` pip install cognis-tfscan tfscan scan . # → prioritized findings in seconds ``` ## 使用说明 — 逐步指南 1. **安装** CLI(控制台脚本 `tfscan`): pip install cognis-tfscan 2. **扫描 Terraform** — `scan` 会遍历 `.tf` / `.tf.json` 文件、目录或 plan 文件以发现配置错误: tfscan scan ./infra 3. **按严重程度过滤 / 更改格式** — 减少干扰信息并输出 JSON 或可共享的 HTML 报告: tfscan scan ./infra --min-severity HIGH tfscan scan ./infra --format html -o report.html 4. **阅读输出** — 每个发现结果都包含 `severity`、`check_id`、`resource`、`file:line` 以及 `remediation`。退出代码:`0` 表示正常,`1` 表示存在发现结果,`2` 表示扫描错误: tfscan scan ./infra --format json | jq '.findings[] | {check_id, severity, resource_name}' 5. **在 CI 中实现自动化** — 阻止引入 HIGH/CRITICAL 配置错误的合并: - run: pip install cognis-tfscan - run: tfscan scan ./infra --min-severity HIGH # 非零退出码会导致任务失败 ## 目录 - [为什么选择 tfscan?](#why) · [功能](#features) · [快速开始](#quick-start) · [示例](#example) · [架构](#architecture) · [AI 技术栈](#ai-stack) · [对比分析](#how-it-compares) · [集成](#integrations) · [随处安装](#install-anywhere) · [相关项目](#related) · [贡献指南](#contributing) ## 为什么选择 tfscan? 扫描 Terraform 计划/配置以发现配置错误 —— 无需搭建重量级的基础设施。 `tfscan` 具备单一用途、可脚本化且支持自托管:将其指向目标,即可通过您工作流中已有的格式(表格 · JSON · SARIF)获取优先级排序的结果,并以此作为 CI 的门禁,让 AI agent 通过 MCP 驱动它。
↑ 回到顶部
## 功能 - ✅ 解析 Hcl - ✅ 解析 Plan Json - ✅ 加载检查规则 - ✅ 扫描文本 - ✅ 扫描路径 - ✅ 可在 Linux/macOS/Windows · Docker · devcontainer 上运行 - ✅ 提供 Python、JavaScript、Go 和 Rust 版本(`ports/`)
↑ 回到顶部
## 快速开始 ``` pip install cognis-tfscan tfscan --version tfscan scan . # scan current project tfscan scan . --format json # machine-readable tfscan scan . --fail-on high # CI gate (non-zero exit) ```
↑ 回到顶部
## 示例 ``` $ tfscan scan . [HIGH ] TFS-001 example finding (./src/app.py) [MEDIUM ] TFS-002 another signal (./config.yaml) 2 findings · risk score 5 · 38ms ```
↑ 回到顶部
## 架构 ``` flowchart LR IN[target / manifest] --> P[tfscan
checks + rules] P --> OUT[findings (JSON / SARIF)] ```
↑ 回到顶部
## 从任何 AI 技术栈中使用 `tfscan` 可以与所有流行的 AI 使用方式实现互操作: - **MCP server** — `tfscan mcp`(Claude Desktop、Cursor、Cognis.Studio、[uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet)) - **OpenAI 兼容 / JSON** — 通过管道将 `tfscan scan . --format json` 传入任何 agent 或 LLM - **LangChain · CrewAI · AutoGen · LlamaIndex** — 一行代码即可将 CLI/JSON 封装为工具 - **CI / 脚本** — 为非 AI 流水线提供退出代码 + SARIF
↑ 回到顶部
## 对比分析 | | **Cognis tfscan** | 典型工具 | |---|:---:|:---:| | 可自托管,无需账户 | ✅ | 视情况而定 | | 单一命令,零配置 | ✅ | ⚠️ | | 用于 CI 的 JSON + SARIF | ✅ | 视情况而定 | | MCP 原生支持(AI agent) | ✅ | ❌ | | 多语言移植版本(JS/Go/Rust) | ✅ | ❌ | | 开源许可证 | ✅ COCL | 视情况而定 |
↑ 回到顶部
## 集成 可以无缝接入您的技术栈:用于代码扫描的 **SARIF**,用于处理一切的 **JSON**,用于 AI agent 的 **MCP server**(`tfscan mcp`),以及用于 SIEM/Slack/Jira 的 webhook 转发器。请参阅 [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md)。
↑ 回到顶部
## 安装 — 全平台、全方式指南 ``` pip install "git+https://github.com/cognis-digital/tfscan.git" # pip (works today) pipx install "git+https://github.com/cognis-digital/tfscan.git" # isolated CLI uv tool install "git+https://github.com/cognis-digital/tfscan.git" # uv pip install cognis-tfscan # PyPI (when published) docker run --rm ghcr.io/cognis-digital/tfscan:latest --help # Docker brew install cognis-digital/tap/tfscan # Homebrew tap curl -fsSL https://raw.githubusercontent.com/cognis-digital/tfscan/main/install.sh | sh ``` | Linux | macOS | Windows | Docker | Cloud | |---|---|---|---|---| | `scripts/setup-linux.sh` | `scripts/setup-macos.sh` | `scripts/setup-windows.ps1` | `docker run ghcr.io/cognis-digital/tfscan` | [DEPLOY.md](docs/DEPLOY.md) (AWS/Azure/GCP/k8s) |
↑ 回到顶部
## 相关的 Cognis 工具 **探索套件 →** [🗂️ 全部 170+ 种工具](https://github.com/cognis-digital/cognis-neural-suite) · [⭐ awesome-cognis](https://github.com/cognis-digital/awesome-cognis) · [🔗 cognis-sources](https://github.com/cognis-digital/cognis-sources) · [🤖 uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet) · [🧠 engram](https://github.com/cognis-digital/engram)
↑ 回到顶部
## 互操作性 `{}` 与包含 300+ 工具的 Cognis 套件无缝组合 — 统一的 JSON 输入/输出以及共享的 OpenAI 兼容的 `/v1` 骨干网络。请参阅 **[INTEROP.md](INTEROP.md)** 了解 套件图谱、组合模式以及参考技术栈。 ## 许可证 在 **Cognis Open Collaboration License (COCL) v1.0** 下开源可见 — 个人、内部评估、研究和教育用途免费;**商业 / 生产环境使用需要获取许可证** (licensing@cognis.digital)。请参阅 [LICENSE](LICENSE)。
Cognis Digital · Cognis Neural Suite 中 170+ 种工具之一 · Making Tomorrow Better Today
标签:DevSecOps, ECS, Terraform, 上游代理, 可视化界面, 安全合规, 数据可视化, 日志审计, 网络代理, 请求拦截, 逆向工具, 错误基检测, 静态代码分析