Skip to content

Commit 86d90eb

Browse files
mithroclaude
andcommitted
Fix gitleaks security configuration issues
Improved gitleaks configuration based on code review feedback: 1. Database password allowlist - Changed from broad pattern that would match any string containing 'postgres' to specific pattern that only matches literal 'postgres' password in connection strings (postgres://user:postgres@host) 2. Django SECRET_KEY detection - Added allowlist to existing rule for env() calls and get_random_secret_key() generator. Added new rule 'django-secret-key-in-default' to detect hardcoded secrets in env() default parameters. 3. Path allowlisting - Removed overly broad directory allowlists: - tests/ (should validate actual secret content) - .github/workflows/ (CI credentials need validation) - config/settings/base.py (settings files need validation) - deployment/scripts/ (deployment scripts need validation) These changes improve secret detection accuracy by being more specific in allowlists and removing blanket directory exclusions. Addresses code review feedback from CodeRabbit and Claude bot on PR #42. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a5a3d19 commit 86d90eb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.gitleaks.toml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ paths = [
1010
'''\.env\.example$''', # Template files are safe
1111
'''\.env\.production\.template$''', # Production template is safe
1212
'''docs/''', # Documentation files
13-
'''tests/''', # All test files with fake OAuth secrets
14-
'''\.github/workflows/''', # CI configuration with test database credentials
15-
'''config/settings/base\.py$''', # Base settings with dev defaults and admin emails
1613
'''\.venv/''', # Virtual environment
1714
'''\.worktrees/''', # Git worktrees
1815
'''node_modules/''', # Node modules
1916
'''staticfiles/''', # Collected static files
20-
'''deployment/scripts/''', # Deployment scripts manage secrets safely
2117
]
2218

2319
# Common patterns for test files with fake credentials
@@ -35,9 +31,20 @@ regexes = [
3531
# Custom rules for Django/OAuth specific secrets
3632
[[rules]]
3733
id = "django-secret-key"
38-
description = "Django SECRET_KEY"
34+
description = "Django SECRET_KEY in assignment"
3935
regex = '''(?i)SECRET_KEY\s*=\s*['"][^'"]{40,}['"]'''
4036
tags = ["django", "secret"]
37+
[rules.allowlist]
38+
regexes = [
39+
'''env\(''', # Allow env() calls - secrets loaded from environment
40+
'''get_random_secret_key\(''', # Allow Django's random secret key generator
41+
]
42+
43+
[[rules]]
44+
id = "django-secret-key-in-default"
45+
description = "Django SECRET_KEY in env() default parameter"
46+
regex = '''env\([^,]+,\s*default\s*=\s*['"][^'"]{40,}['"]'''
47+
tags = ["django", "secret"]
4148

4249
[[rules]]
4350
id = "oauth-client-secret"
@@ -67,7 +74,7 @@ regex = '''postgres://[^:]+:([^@]{8,})@'''
6774
tags = ["database", "password"]
6875
[rules.allowlist]
6976
regexes = [
70-
'''postgres''', # Allow 'postgres' as password in dev/test
77+
'''postgres://[^:]+:postgres@''', # Allow literal 'postgres' password only
7178
]
7279

7380
[[rules]]

0 commit comments

Comments
 (0)