用途:在 DevSecOps 流程中检测和预防硬编码凭据。Gitleaks 结合正则匹配与香农熵分析,扫描 Git 仓库、文件与目录中的密码、API Key、令牌等敏感信息。
主要能力:仓库扫描(detect)、提交前钩子保护(protect --staged)、CI/CD 集成(GitHub Actions、GitLab CI 等)、基线与增量扫描、自定义规则与允许列表、多种报告格式(JSON、SARIF)、熵检测与复合规则。
使用方式:安装 gitleaks(如 brew install gitleaks 或 docker pull zricethezav/gitleaks:latest);扫描当前仓库用 gitleaks detect -v;扫描指定目录用 gitleaks detect --source /path/to/code -v;生成报告用 gitleaks detect --report-path gitleaks-report.json --report-format json。提交前钩子可执行 gitleaks protect --verbose --redact --staged。CI 中可用 gitleaks/gitleaks-action@v2 或 Docker 镜像 zricethezav/gitleaks:latest。
适用场景:初次安全审计、合规检查、事件响应、开发工作站保护、Pull Request 检查、遗留代码治理与合规追踪。
限制与注意事项:扫描日志与报告应使用 --redact 并视为机密;Git 历史中已泄露的密钥需用 git filter-repo 或 BFG 清理并立即轮换;大仓库性能问题可用 --log-opts 限制历史范围或基线方式优化。该资料未提供具体收费、价格与平台信息。