We use multiple tools to detect secrets and sensitive information in our codebase:
- What it does: Detects secrets using entropy analysis and regex patterns
- Why we use it: Free, no license required, very effective
- Runs on: Every push and pull request via GitHub Actions
- What it does: Detects secrets using configurable rules
- Configuration:
.gitleaks.tomlin the root directory - Usage: Primarily for local development
Our security workflow (.github/workflows/security.yml) includes:
- Secret Detection - Uses TruffleHog + local gitleaks
- Dependency Scanning - Uses npm audit for vulnerability checking
- SARIF Upload - Results are uploaded to GitHub Security tab
# Run gitleaks scan
npm run security:scan
# Run TruffleHog scan (requires Docker)
npm run security:trufflehog
# Run both scans
npm run security:full
# Scan only staged files (good for pre-commit)
npm run security:scan-staged
# Create baseline file to ignore existing findings
npm run security:baselineThe precommit script runs automatically before commits to check staged files:
npm run precommitOur configuration includes:
- Custom rules for Supabase keys
- NextAuth and JWT secret detection
- Allowlist for false positives
- Stopwords to reduce noise
TruffleHog runs with:
--only-verifiedflag to reduce false positives--debugfor detailed output in CI
- Add patterns to the allowlist in
.gitleaks.toml - Use the baseline file for persistent ignores
- Solution: We've switched to TruffleHog for CI/CD
- Local use: Gitleaks is still free for local development
- TruffleHog: Requires Docker for local usage
- Gitleaks: Install via
brew install gitleaksor run setup script
- Never commit secrets - Use environment variables
- Use .env.local for local development secrets
- Run security scans before committing
- Review scan results carefully
- Update configurations as needed
If secrets are accidentally committed:
- Immediately rotate the compromised credentials
- Remove from git history using
git filter-branchor BFG - Update baseline if needed
- Notify team about the incident