gitleaks

检测仓库中的密钥与敏感信息

补充说明

gitleaks 扫描 Git 历史、工作区和暂存区中的密钥、token、私钥和密码模式,适合提交前检查和 CI 门禁。

常用示例

gitleaks detect --source . --report-format json --report-path leaks.json
gitleaks detect --source . --no-git
gitleaks protect --staged
gitleaks git --log-opts="--since=2026-01-01"
gitleaks detect --baseline-path baseline.json

.gitleaks.toml:

[allowlist]
paths = [
  '''docs/examples/.*''',
]
regexes = [
  '''AKIAIOSFODNN7EXAMPLE''',
]

易错点与排错

相关命令