Skip to content

Add secret prevention: gitleaks pre-commit hook and .gitignore expansion#2201

Open
martijnbar wants to merge 1 commit intoai/mainfrom
ai/feature/secret-prevention-martijn-04-15-2026
Open

Add secret prevention: gitleaks pre-commit hook and .gitignore expansion#2201
martijnbar wants to merge 1 commit intoai/mainfrom
ai/feature/secret-prevention-martijn-04-15-2026

Conversation

@martijnbar
Copy link
Copy Markdown
Contributor

@martijnbar martijnbar commented Apr 15, 2026

Summary

  • Add gitleaks secret scanning to the pre-commit hook (all branches). Commits are blocked if gitleaks is not installed or if secrets are detected in staged files.
  • Expand .gitignore with common secret file patterns (.env, *.pem, *.key, *.pfx, credentials.json, etc.)

Companion PR: See ai-prompts PR for Claude rule and settings changes.

Manual action required

  • GitHub repo settings: Enable Push Protection under Settings > Code security and analysis > Secret scanning. This is a server-side safety net that blocks pushes containing known secret patterns.

Test plan

  • Stage a file containing -----BEGIN RSA PRIVATE KEY----- and verify the commit is blocked
  • Temporarily rename gitleaks binary and verify commit shows install instructions and is blocked
  • Create a .env file and verify git status ignores it

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com


This change is Reviewable

- Add gitleaks secret scanning to pre-commit hook (all branches), blocking
  commits if gitleaks is not installed or if secrets are detected in staged files
- Expand .gitignore with common secret file patterns (.env, *.pem, *.key,
  *.pfx, credentials.json, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@lyonsil lyonsil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@lyonsil reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants