This document summarizes the pre-commit configuration and security measures implemented for the MCP ADR Analysis Server.
- Tool: Gitleaks v8.28.0
- Configuration:
.gitleaks.toml - Features:
- Scans for common secrets (API keys, tokens, credentials)
- Custom rules for Twilio SID, Stripe keys, OpenRouter keys
- Smart allowlist for test files and placeholders
- Integrated into both pre-commit and pre-push hooks
- Security checks:
- Gitleaks secret scanning
- Private key detection (excluding test patterns)
- Code quality:
- Code formatting with Prettier via lint-staged
- TypeScript type checking
- Project build validation
- Smoke test execution
- Final security scan: Comprehensive gitleaks check
- Dependency security: npm audit for vulnerabilities
- Build validation: Ensures clean build before push
- Test suite: Runs full test suite (allows performance test failures)
- Extends default gitleaks configuration
- Custom rules for project-specific secrets
- Smart allowlisting for test files and safe patterns
- Comprehensive pre-commit framework configuration
- Multiple hooks for security, formatting, and quality
- Integrates with existing tools
-
Secret Detection Issue:
- Fixed Twilio Account SID in
tests/utils/tree-sitter-analyzer.test.ts:781 - Replaced test credentials with safe placeholder patterns
- Fixed Twilio Account SID in
-
Security Gaps:
- Added comprehensive secret scanning
- Implemented private key detection
- Added dependency vulnerability checks
-
Hook Optimization:
- Enhanced error handling and user feedback
- Balanced security with developer experience
- Graceful handling of test failures
brew install gitleaks # For secret scanning
npm install # Install project dependencies- Pre-commit: Runs on every commit
- Pre-push: Runs before pushing to remote
# Test secret scanning
gitleaks detect --source . --verbose
# Test pre-commit hook
./.husky/pre-commit
# Test pre-push hook
./.husky/pre-push-
For Developers:
- Use placeholder values for secrets in tests (e.g.,
ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) - Review security warnings before bypassing
- Keep dependencies updated
- Use placeholder values for secrets in tests (e.g.,
-
For Test Files:
- Use clearly identifiable placeholder patterns
- Document test data as non-real in comments
- Follow established patterns for consistency
-
For CI/CD:
- Hooks run locally and in CI environments
- Build failures block pushes for security
- Test failures are logged but don't block (for known performance test issues)
- Gitleaks false positives: Add patterns to
.gitleaks.tomlallowlist - Build failures: Check TypeScript compilation and dependencies
- Test failures: Performance tests may fail intermittently (allowed)
git commit --no-verify # Skip pre-commit
git push --no-verify # Skip pre-pushNote: Only use --no-verify in emergencies and address issues immediately after.