Barrie20/terradrift

GitHub: Barrie20/terradrift

TerraDrift是一个实证研究公共Terraform模块中安全配置漂移现象的工具。

Stars: 0 | Forks: 0

# 🌊 TerraDrift **一项关于公共 Terraform 模块中安全漂移现象的实证研究。** [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/defb2ee430144832.svg)](https://github.com/Barrie20/terradrift/actions/workflows/ci.yml) [![Security](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/87c76515bd144838.svg)](https://github.com/Barrie20/terradrift/actions/workflows/security.yml) [![SLSA Level 3](https://slsa.dev/images/gh-badge-level3.svg)](https://slsa.dev) [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE) [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/) [![arXiv](https://img.shields.io/badge/arXiv-soon-red.svg)](#)
## 🎯 什么是 TerraDrift? TerraDrift 通过大规模挖掘**公共 Terraform 仓库**来回答一个问题: **现实类比:** 可以将 TerraDrift 想象成云基础设施的 Fitbit。就像 Fitbit 衡量你不去健身房的频率一样,TerraDrift 衡量公司跳过云安全最佳实践的频率,以及这些不良习惯持续的时间。 ### 目标会议 - 📄 **MSR 2026** 软件仓库挖掘 — 挖掘挑战 / 技术专题 - 📄 **USENIX SCORED 2026** 研讨会 (备选) ## 🧭 30 秒概要 | 问题 | 答案 | |---|---| | 影响谁? | GitHub 上的公共 Terraform 模块 | | 我们衡量什么 | 错误配置生命周期(引入 → 检测到 → 修复 → 回退) | | 规模多大 | 超过 12,000 个模块,400 万+次提交 | | 我们产出什么 | 开放数据集 + 分析管道 + 论文 | | 为何重要 | 41% 的云泄露始于 IaC 漂移(Wiz, 2024) | ## 🏗️ 架构(一图流) ``` flowchart LR A[GitHub GraphQL API] -->|crawl.py| B[(Parquet corpus on S3)] B --> C[AWS Batch fan-out] C --> D[tree-sitter HCL parser] D --> E[Drift detector] D --> F[Checkov / Trivy / tfsec] E --> G[(DuckDB analytics)] F --> G G --> H[Notebooks + paper figs] G --> I[Public API - FastAPI on EKS] I --> J[Grafana dashboard] K[OPA Gatekeeper] -.policy gate.-> I L[OTEL collector] --> M[Prometheus + Loki] I --> L ``` ## 🚀 快速开始(三行命令) ``` git clone https://github.com/Barrie20/terradrift.git cd terradrift make demo # scans the included sample Terraform repo ``` 你将看到:一份 CSV 报告,其中包含了发现的错误配置,并按 17 个类别进行了分类。 ## 📚 三份 README,面向三类读者 | 如果你是... | 请阅读此文件 | |---|---| | **招聘人员 / 招聘经理** | 此 `README.md` | | **研究人员 / 博士申请审阅者** | [`README.research.md`](README.research.md) | | **IaC 安全新手** | [`README.beginner.md`](README.beginner.md) | ## 🧱 仓库结构 ``` terradrift/ ├── corpus/ # crawler + manifest of mined repos ├── src/terradrift/ # parser, drift detector, classifier, CLI ├── notebooks/ # exploratory data analysis ├── infra/terraform/ # AWS Batch + S3 pipeline (IaC for the IaC scanner) ├── docs/ # ARCHITECTURE, SECURITY, THREAT_MODEL, RUNBOOK ├── benchmarks/ # nightly perf runs, auto-updated results.md ├── tests/ # unit / integration / e2e / chaos ├── .github/workflows/ # CI, security gates, SLSA, journal, diagrams └── docs/paper/ # ACM LaTeX template — the actual paper ``` ## 🔐 安全姿态 - ✅ SLSA Level 3 构建来源证明 (Sigstore + Cosign) - ✅ 每个发布版本包含 SBOM (SPDX) - ✅ 每晚对 IaC 和 Python 代码运行 Trivy + Checkov + Semgrep - ✅ Distroless 容器、非 root 用户、只读根文件系统 - ✅ 所有提交均已签名 (`-S`),强制使用约定式提交 详见 [`docs/SECURITY.md`](docs/SECURITY.md) 和 [`docs/THREAT_MODEL.md`](docs/THREAT_MODEL.md)。 ## 📊 最新夜间测试结果 *由 `.github/workflows/benchmark.yml` 于 UTC 05:00 更新。* | 指标 | 值 | |---|---| | 已扫描模块数 | _(每夜自动填充)_ | | 每模块中位扫描时间 | _(每夜自动填充)_ | | 检测到的总错误配置数 | _(每夜自动填充)_ | ## 🤝 引用方式 ``` @misc{terradrift2026, title = {TerraDrift: An Empirical Study of Security Drift in Public Terraform Modules}, author = {Barrie, [Full Name]}, year = {2026}, url = {https://github.com/Barrie20/terradrift} } ``` ## 📜 许可证 Apache-2.0。详见 [LICENSE](LICENSE)。
标签:AWS Batch, DuckDB, ECS, GitHub API, HCL解析, MSR 2026, Parquet, Python开发, SMB, Terraform, tfsec, tree-sitter, 二进制发布, 云基础设施, 代码示例, 代码解析, 安全漂移, 安全生命周期, 实证研究, 开源工具, 批处理, 数据分析, 漏洞利用检测, 自定义请求头, 软件仓库挖掘, 逆向工具, 错误配置检测