9t29zhmwdh-coder/github-actions-security-sandbox
GitHub: 9t29zhmwdh-coder/github-actions-security-sandbox
一款 Rust 编写的 GitHub Actions 工作流安全静态分析工具,通过检测注入向量、权限滥用和供应链风险来帮助团队在 CI 流水线中发现并修复安全配置问题。
Stars: 0 | Forks: 0
GitHub Actions Security Sandbox Simulator
**针对 GitHub Actions 工作流的静态分析与攻击模拟。可检测注入向量、供应链风险、过度权限及机密信息暴露。生成带有修复指导的优先级报告。**
符合 [Microsoft Security DevOps](https://learn.microsoft.com/en-us/azure/defender-for-cloud/azure-devops-extension) 原则。SARIF 2.1.0 输出可与 [GitHub Advanced Security (GHAS)](https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security) 代码扫描原生集成,适用于企业级安全工作流。
[](https://github.com/9t29zhmwdh-coder/github-actions-security-sandbox/actions)    
[](https://github.com/9t29zhmwdh-coder/github-actions-security-sandbox)
[](LICENSE)
[](docs/threat_model.md)
[](https://github.com/9t29zhmwdh-coder/github-actions-security-sandbox/actions/workflows/ci.yml)
## 检测到的攻击向量
| 攻击向量 | 严重性 | CWE |
|---|---|---|
| 通过不受信任的 context 表达式进行的脚本注入 | Critical | CWE-78 |
| Pwn Request (pull_request_target + PR head checkout) | Critical | CWE-913 |
| 过度权限 (write-all, contents: write) | High | CWE-250 |
| 将 Secrets 传递给第三方 action | High | CWE-522 |
| 未锁定的 action (可变的分支引用) | High | CWE-829 |
| 未锁定的 action (语义版本标签) | Medium | CWE-829 |
| 未隔离的自托管 Runner | Medium | CWE-653 |
| 环境变量中的 Secret 值 | Informational | CWE-532 |
## 快速开始
```
git clone https://github.com/9t29zhmwdh-coder/github-actions-security-sandbox
cd github-actions-security-sandbox
cargo build --release
# 扫描单个 workflow 文件
./target/release/ghass scan examples/vulnerable_workflow.yml
# 扫描目录中的所有 workflow
./target/release/ghass scan .github/workflows
# 将 finding 导出为 Markdown
./target/release/ghass scan .github/workflows --format md --output report.md
# 为 GitHub Advanced Security 导出 SARIF
./target/release/ghass scan .github/workflows --format sarif --output results.sarif
# 仅显示 high severity 及以上
./target/release/ghass scan .github/workflows --min-severity high
```
## 输出格式
| 格式 | 标志 | 使用场景 |
|---|---|---|
| 表格 (默认) | `--format table` | 交互式终端检查 |
| JSON | `--format json` | CI pipeline、工单系统集成 |
| Markdown | `--format md` | PR 评论、Confluence、内部报告 |
| HTML | `--format html` | 供利益相关者通过浏览器查看的报告 |
| SARIF | `--format sarif` | GitHub Advanced Security、代码扫描 |
## 发现严重性
| 严重性 | 描述 |
|---|---|
| Critical | 立即执行代码的风险或机密信息完全暴露。合并前必须修复。 |
| High | 可在中等努力下被利用的重大风险。 |
| Medium | 风险需要特定条件才能被利用;在下一个 sprint 中修复。 |
| Low | 纵深防御改进,直接影响有限。 |
| Informational | 正确的使用模式;审查其完整性。 |
## 架构
该工具的结构为一个包含三个 crate 的 Rust workspace:
| Crate | 角色 |
|---|---|
| `ghass-core` | 领域模型、发现类型、报告序列化 (JSON, Markdown, HTML, SARIF) |
| `ghass-scan` | YAML 工作流解析器、所有安全分析器 |
| `ghass-cli` | CLI 二进制文件 (`ghass`)、输出格式化、严重性过滤 |
有关完整的数据流图和模块说明,请参阅 [ARCHITECTURE.md](ARCHITECTURE.md)。
## GitHub Action 集成
将本仓库中的 `.github/workflows/ghass-check-template.yml` 复制到您自己的项目中,即可在每次 push 和每周计划任务中自动扫描工作流。结果将作为 SARIF 结果上传至 GitHub Advanced Security。
有关每种发现类型的加固模式,请参阅 [docs/attack_vectors.md](docs/attack_vectors.md)。
## 无需凭据
此工具执行完全本地的静态分析。它从磁盘读取 YAML 文件。不需要也不使用任何 Azure、GitHub 或任何其他 API 凭据。
**作者:** [Rafael Yilmaz](https://github.com/9t29zhmwdh-coder) · **状态:** 活跃 · v0.1.0 · **许可证:** MIT
标签:CI/CD安全, DevSecOps, GitHub Actions, Llama, Rust, SARIF, 上游代理, 可视化界面, 攻击模拟, 文档安全, 文档结构分析, 网络流量审计, 自动笔记, 通知系统, 错误基检测, 静态代码分析, 驱动签名利用