-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(security): Integrate TruffleHog/GitLeaks for automatic secret scanning #17551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(security): Integrate TruffleHog/GitLeaks for automatic secret scanning #17551
Conversation
…anning Following maintainer feedback on PR anthropics#15040, this integrates with existing well-maintained secret scanning tools rather than reinventing detection. When Claude Code performs git commits: - If TruffleHog/GitLeaks installed: automatically scans staged files - If secrets detected: blocks commit with clear error message - If no tools installed: shows one-time warning with install instructions This addresses the architectural gap identified in Issues anthropics#2142 and anthropics#12524 where Claude Code commits automatically without any secret detection, resulting in credential exposure. Key design decisions: - Leverages existing tools (TruffleHog has 800+ detection patterns) - Zero maintenance burden for detection patterns - Non-blocking when tools unavailable (just warns) - Respects DISABLE_SECRET_SCANNING env var Fixes: anthropics#2142, anthropics#12524 Related: PR anthropics#15040 (original proposal, led to this approach) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Summary
Following @ddworken's feedback on PR #15040:
This PR implements that guidance by integrating with existing tools rather than reinventing detection.
What This Does
When Claude Code performs
git commit:Why This Matters
Issues #2142 and #12524 document real incidents where Claude Code committed credentials:
Both incidents had CLAUDE.md files with security commands. The problem wasn't lack of user awareness—it was that Claude Code commits automatically without any protection.
Design Decisions
DISABLE_SECRET_SCANNING=1disables the hookImplementation Details
New File:
secret_scanning_integration_hook.pygit commitcommands via PreToolUse hooktrufflehog) or GitLeaks (gitleaks) in PATHModified:
hooks.jsonFiles Changed
Testing
Related
This directly implements @ddworken's suggestion: integrate with specialized tools rather than building custom detection.
🤖 Generated with Claude Code
Co-authored-by: Claude Opus 4.5 [email protected]