secrets-scan
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecrets Scan
机密信息扫描
Detect hardcoded secrets by following the full procedure in .
plays/secrets-scan.md通过遵循中的完整流程检测硬编码机密信息。
plays/secrets-scan.mdSteps
步骤
-
Run Automated Scanner — Use available tools in preference order:
- (recommended)
trufflehog filesystem --directory=<path> --json - (includes git history)
trufflehog git file://<repo> --json gitleaks detect --source=<path> --report-format=jsondetect-secrets scan <path> --all-files- If no scanner available, proceed with manual pattern analysis.
-
Manual Pattern Analysis — Search for high-confidence patterns:
- AWS keys (), OpenAI (
AKIA...), Anthropic (sk-...), GitHub (sk-ant-...), Slack (ghp_...), Stripe (xoxb-...), SendGrid (sk_live_...)SG. - Connection strings with embedded passwords ()
://user:pass@host - Private keys (PEM headers), JWT secrets, database credentials
- High-risk files: ,
.env,docker-compose*.yml,*.tfvars,terraform.tfstate,kubeconfig,.npmrc.pypirc
- AWS keys (
-
Contextual Analysis — For each detection: Is it real (not a placeholder/test fixture)? Is it active? What's the blast radius (service, permissions, prod vs dev, exposure duration)?
-
Check Preventive Controls — Verify:covers sensitive files, pre-commit hooks for secret scanning, CI pipeline scanning, secrets management documentation.
.gitignore
Important: Never include actual secret values in findings. Show redacted versions only (e.g., ). Active production secrets require immediate rotation.
AKIA****EXAMPLE-
运行自动化扫描工具 — 按优先级使用可用工具:
- (推荐)
trufflehog filesystem --directory=<path> --json - (包含Git历史记录)
trufflehog git file://<repo> --json gitleaks detect --source=<path> --report-format=jsondetect-secrets scan <path> --all-files- 若没有可用扫描工具,则进行手动模式分析。
-
手动模式分析 — 搜索高可信度模式:
- AWS密钥()、OpenAI密钥(
AKIA...)、Anthropic密钥(sk-...)、GitHub密钥(sk-ant-...)、Slack令牌(ghp_...)、Stripe密钥(xoxb-...)、SendGrid密钥(sk_live_...)SG. - 包含嵌入密码的连接字符串()
://user:pass@host - 私钥(PEM头)、JWT机密、数据库凭证
- 高风险文件:、
.env、docker-compose*.yml、*.tfvars、terraform.tfstate、kubeconfig、.npmrc.pypirc
- AWS密钥(
-
上下文分析 — 针对每个检测结果:是否为真实机密(而非占位符/测试用例)?是否处于活跃状态?影响范围有多大(涉及服务、权限、生产环境vs开发环境、暴露时长)?
-
检查预防性控制措施 — 验证:是否覆盖敏感文件、是否配置了用于机密扫描的提交前钩子、CI流水线是否包含扫描环节、是否有机密管理文档。
.gitignore
重要提示:切勿在检测结果中包含真实机密值,仅展示脱敏版本(例如:)。活跃的生产环境机密需立即轮换。
AKIA****EXAMPLEOutput
输出内容
Scan summary, findings using , preventive controls checklist, and immediate rotation actions if needed.
templates/finding.md扫描摘要、使用生成的检测结果、预防性控制措施检查表,以及必要时的立即轮换操作建议。
templates/finding.mdOWASP References
OWASP参考资料
- A07:2021: Identification and Authentication Failures
- CWE-798: Use of Hard-coded Credentials
- CWE-312: Cleartext Storage of Sensitive Information
- A07:2021: 身份验证与识别失败
- CWE-798: 使用硬编码凭证
- CWE-312: 敏感信息明文存储