Skip to content

Commit e4cecd4

Browse files
committed
security: enhance secret scanner to catch more patterns and scan markdown files
- Add detection for Vercel tokens (VERCEL_TOKEN) - Add detection for PostgreSQL connection strings with passwords - Add detection for Stripe webhook secrets (whsec_*) - Add detection for Stripe publishable keys (pk_*) - Add detection for Currents.dev API keys - Include .md files in scan (previously only scanned code files) This would have prevented the secrets exposure in SCRATCHPAD.md that required git history rewrite in commit 3ceef43.
1 parent 3ceef43 commit e4cecd4

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

scripts/check-secrets.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,33 @@ PATTERNS=(
1313
# Stripe
1414
"sk_live_[0-9a-zA-Z]{24,}"
1515
"sk_test_[0-9a-zA-Z]{24,}"
16-
16+
"pk_live_[0-9a-zA-Z]{24,}"
17+
"pk_test_[0-9a-zA-Z]{24,}"
18+
"whsec_[0-9a-zA-Z]{24,}"
19+
20+
# Vercel
21+
"VERCEL_TOKEN[\"']?\s*[:=]\s*[\"']?[0-9a-zA-Z]{16,}"
22+
"vercel_token[\"']?\s*[:=]\s*[\"']?[0-9a-zA-Z]{16,}"
23+
24+
# PostgreSQL connection strings with passwords
25+
"postgresql://[^:]+:[^@]+@"
26+
"postgres://[^:]+:[^@]+@"
27+
28+
# Currents.dev (test reporting service)
29+
"CURRENTS_API_KEY[\"']?\s*[:=]\s*[\"'][^\"']{32,}"
30+
"CURRENTS_RECORD_KEY[\"']?\s*[:=]\s*[\"'][^\"']{8,}"
31+
"CURRENTS_PROJECT_ID[\"']?\s*[:=]\s*[\"'][^\"']{6,}"
32+
1733
# SendGrid
1834
"SG\.[a-zA-Z0-9_-]{22}\.[a-zA-Z0-9_-]{43}"
19-
35+
2036
# Generic API keys
2137
"api[_-]?key[\"']?\s*[:=]\s*[\"'][^\"']{32,}"
2238
"secret[_-]?key[\"']?\s*[:=]\s*[\"'][^\"']{32,}"
23-
39+
2440
# AWS
2541
"AKIA[0-9A-Z]{16}"
26-
42+
2743
# GitHub
2844
"ghp_[0-9a-zA-Z]{36}"
2945
"gho_[0-9a-zA-Z]{36}"
@@ -42,8 +58,8 @@ FOUND_SECRETS=0
4258

4359
# Check each pattern only in staged files
4460
for pattern in "${PATTERNS[@]}"; do
45-
# Get list of staged files
46-
staged_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|json|env)$' | grep -v '.env.test')
61+
# Get list of staged files (including markdown for documentation)
62+
staged_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|json|env|md)$' | grep -v '.env.test')
4763

4864
if [ ! -z "$staged_files" ]; then
4965
# Search for pattern only in staged files

0 commit comments

Comments
 (0)