implementing-secrets-scanning-in-ci-cd
它能做什么
这个工具可以帮助找出被意外写入项目代码中的敏感信息(比如密码或 API 密钥)。它会在代码发布到生产环境之前进行检查,防止安全泄露。
适用场景
- ✓在设置项目安全时。
- ✓在发布新版本软件之前。
- ✓需要确认敏感信息没有泄露时。
技能链接
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-secrets-scanning-in-ci-cd/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“在发布之前,扫描我的代码,看看是否有泄露的敏感信息。”
每周 5 个新技能,1 分钟读完。
工作原理
该工具借助其他程序(Gitleaks 和 TruffleHog)在代码中查找敏感信息的特征模式。如果发现可疑内容,它会提醒你,甚至可以阻止代码被发布。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Implementing Secrets Scanning in CI/CD
Overview
This skill covers implementing automated secrets scanning in CI/CD pipelines using gitleaks and trufflehog. It enables security teams to detect API keys, tokens, passwords, and other credentials that have been accidentally committed to source code repositories, providing a CI gate that blocks deployments containing high-severity findings.
Gitleaks scans git repositories and directories for hardcoded secrets using regex patterns and entropy analysis. TruffleHog performs filesystem and git history scans with optional secret verification against live services. Together they provide comprehensive coverage for secrets detection.
When to Use
- When deploying or configuring implementing secrets scanning in ci cd capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation
Prerequisites
- Python 3.9 or later
- gitleaks v8.x installed and available on PATH
- trufflehog v3.x installed and available on PATH
- A git repository or directory to scan
- Access to CI/CD platform (GitHub Actions, GitLab CI, Jenkins)
Steps
Install scanning tools: Install gitleaks via package manager or binary download. Install trufflehog via
brew install trufflehogor download from GitHub releases.Configure gitleaks: Create a
.gitleaks.tomlconfiguration file in the repository root to define custom rules, allowlists, and path exclusions. Use--configflag to point to custom configs.Run gitleaks directory scan: Execute
gitleaks dir --source . --report-format json --report-path gitleaks-report.jsonto scan the working directory and generate a JSON report.Run trufflehog filesystem scan: Execute
trufflehog filesystem /path/to/repo --json > trufflehog-report.jsonto scan files and output JSON findings to a report file.Parse and filter findings: Use the agent script to parse both JSON reports, filter findings by severity (critical, high, medium, low), and determine whether the CI pipeline should pass or fail.
Integrate into CI pipeline: Add the scanning step to your GitHub Actions workflow, GitLab CI config, or Jenkins pipeline as a pre-deployment gate. Use
--exit-codeflag in gitleaks to control pipeline behavior.Configure pre-commit hooks: Set up gitleaks as a pre-commit hook using
gitleaks protect --stagedto catch secrets before they are committed.Review and triage findings: Examine the JSON output for false positives, add legitimate entries to
.gitleaksignore, and rotate any confirmed leaked credentials immediately.
Expected Output
The agent script produces a JSON report containing:
- Total findings count from each scanner
- Findings grouped by severity level
- Individual finding details including file path, line number, rule ID, and redacted secret
- A CI gate verdict (pass/fail) based on the configured severity threshold
- Execution metadata including scan duration and tool versions
{
"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": [...]
}
常见问题
什么是敏感信息?
敏感信息指密码、API 密钥、访问令牌以及其他不应在代码中公开的凭据。
什么是 CI/CD?
CI/CD 是一种自动化软件构建、测试和交付的流程。这个工具融入该流程,为其增加一层安全防护。
如果工具发现了敏感信息会怎样?
它可以阻止代码被发布,并生成详细报告,列出发现的内容,方便你修复问题。
详情
作者的原始描述
Integrate gitleaks and trufflehog into CI/CD pipelines to detect leaked secrets before deployment
热度
- GitHub 星标
- 35k
- 排名
- #8115
- 许可证
- Apache-2.0
- 更新时间
- 2026/8/31
评论
- …
同一仓库的更多技能
abusing-dpapi-for-credential-access
35k为你的 AI 智能体提供针对特定任务的现成指令,让它完成得更好、更快。
abusing-shadow-credentials-for-privesc
35k教你的 AI 智能体写出清晰、结构良好的文本。
achieving-cmmc-level-2-compliance
35k帮助你的智能体搭建符合 CMMC Level 2 合规要求的环境。它会落实安全要求,并管理必要的文档。
acquiring-disk-image-with-dd-and-dcfldd
35k帮助你的智能体创建硬盘的精确副本。这能确保调查过程中信息不丢失、不被篡改。