检测仓库中的密钥与敏感信息
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''',
]
protect --staged 适合 pre-commit,但要确保钩子真正安装。合上页面,先回答,再展开对照。
小程序版
微信扫码,随时查命令