ziaongit/github-actions-security-gates

GitHub: ziaongit/github-actions-security-gates

该项目演示在 GitHub Actions 中集成 Snyk、Trivy、CodeQL、OWASP ZAP 四道自动化安全门控,帮助团队在 CI/CD 流水线中实现安全左移。

Stars: 0 | Forks: 0

# github-actions-security-gates 演示在 GitHub Actions 中实现 4 个自动化安全门控的 Node.js Express API 示例。 专为 DevOps.com 文章构建:**Shift Left Security:GitHub Actions 中的 4 个自动化安全门控** ## 4 个门控 | 门控 | 工具 | 发现内容 | 是否中断构建? | |------|------|---------------|-------------| | 1 | npm audit + Snyk | npm 包中的 CVE | 是 (HIGH/CRITICAL) | | 2 | Trivy | Docker 基础镜像中的 CVE | 是 (HIGH/CRITICAL) | | 3 | CodeQL | SQL injection、XSS、硬编码密钥 | 是 (HIGH) | | 4 | OWASP ZAP | 运行中应用的运行时漏洞 | 仅警告 | ## 项目结构 ``` ├── .github/ │ └── workflows/ │ └── security-gates.yml # Combined 4-gate pipeline ├── src/ │ └── app.js # Express API (ZAP scan target) ├── .snyk # Snyk CVE suppressions ├── .trivyignore # Trivy CVE suppressions ├── .zap/ │ └── rules.tsv # ZAP false positive suppressions ├── .env.example ├── Dockerfile ├── docker-compose.yml └── package.json ``` ## 本地运行 ``` git clone https://github.com/ziaongit/github-actions-security-gates cd github-actions-security-gates cp .env.example .env npm install npm start ``` 应用运行在 http://localhost:3000 ## 本地运行安全扫描 **门控 1 — 依赖扫描:** ``` npm audit --audit-level=high ``` **门控 2 — 镜像扫描(通过 Docker,无需安装 Trivy):** ``` docker build -t myapp:local . docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image --severity HIGH,CRITICAL myapp:local ``` **门控 4 — ZAP 基线扫描:** ``` # 首先停止任何正在运行的 app(npm start 必须不能在端口 3000 上运行) docker compose up -d docker run -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t http://host.docker.internal:3000 docker compose down ``` ## 所需的 GitHub Secrets | Secret | 获取方式 | |--------|----------------| | `SNYK_TOKEN` | snyk.io → 账户设置 → Auth Token | ## 作者 Zia Ullah — [github.com/ziaongit](https://github.com/ziaongit)
标签:AI应用开发, DevSecOps, Express, GitHub Actions, GNU通用公共许可证, MITM代理, Node.js, 上游代理, 安全专业人员, 安全扫描, 时序注入, 自动笔记, 自定义脚本, 请求拦截