/cybersecurity-skills-zh:implementing-secrets-scanning-in-ci-cdfrom cybersecurity-skills-zh
Integrates gitleaks and trufflehog into CI/CD pipelines to detect leaked secrets before deployment. Generates JSON reports with severity-based findings and CI gate decisions.
Ships in cybersecurity-skills-zh. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
本技能涵盖使用 gitleaks 和 trufflehog 在 CI/CD 管道中实施自动化机密扫描。它使安全团队能够检测意外提交到源代码仓库的 API 密钥、令牌、密码和其他凭证,提供阻止包含高严重性发现的部署的 CI 门禁。
Gitleaks 使用正则表达式模式和熵分析扫描 git 仓库和目录中的硬编码机密。TruffleHog 对文件系统和 git 历史进行扫描,并可选择对实时服务进行机密验证。两者共同为机密检测提供全面覆盖。
安装扫描工具:通过包管理器或二进制下载安装 gitleaks。通过 brew install trufflehog 或从 GitHub releases 下载安装 trufflehog。
配置 gitleaks:在仓库根目录创建 .gitleaks.toml 配置文件,以定义自定义规则、允许列表和路径排除。使用 --config 标志指向自定义配置。
运行 gitleaks 目录扫描:执行 gitleaks dir --source . --report-format json --report-path gitleaks-report.json 以扫描工作目录并生成 JSON 报告。
运行 trufflehog 文件系统扫描:执行 trufflehog filesystem /path/to/repo --json > trufflehog-report.json 以扫描文件并将 JSON 发现输出到报告文件。
解析和过滤发现:使用代理脚本解析两个 JSON 报告,按严重性(严重、高危、中危、低危)过滤发现,并确定 CI 管道是否应通过或失败。
集成到 CI 管道:将扫描步骤添加到 GitHub Actions 工作流、GitLab CI 配置或 Jenkins 管道中,作为预部署门禁。使用 gitleaks 中的 --exit-code 标志控制管道行为。
配置预提交钩子:使用 gitleaks protect --staged 将 gitleaks 设置为预提交钩子,以在提交之前捕获机密。
审查和分类发现:检查 JSON 输出中的误报,将合法条目添加到 .gitleaksignore,并立即轮换任何已确认泄露的凭证。
代理脚本生成包含以下内容的 JSON 报告:
{
"scan_summary": {
"tool": "both",
"total_findings": 3,
"critical": 1,
"high": 1,
"medium": 1,
"low": 0,
"ci_gate": "FAIL",
"fail_reason": "Found 1 critical and 1 high severity findings"
},
"findings": [...]
}
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
secrets-scanning, gitleaks, trufflehog, ci-cd-security, secret-detection
npx claudepluginhub killvxk/cybersecurity-skills-zh --plugin cybersecurity-skills-zh735 skills in this plugin
/acquiring-disk-image-with-dd-and-dcfldd使用 dd 和 dcfldd 创建取证级逐位磁盘镜像,通过哈希验证保持证据完整性。/analyzing-active-directory-acl-abuse使用 ldap3 检测 Active Directory 中危险的 ACL 配置错误,识别 GenericAll、WriteDACL 和 WriteOwner 等滥用路径/analyzing-android-malware-with-apktool使用 apktool 进行反编译、jadx 恢复 Java 源码、androguard 进行权限分析,对 Android APK 恶意软件样本执行静态分析,包括清单检查和可疑 API 调用检测。Other plugins' skills for the same job