Repository navigation
Expand file tree
/
Copy path.gitleaks.toml
More file actions
271 lines (242 loc) · 7.93 KB
/
Copy path.gitleaks.toml
File metadata and controls
271 lines (242 loc) · 7.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# Gitleaks configuration for bitbucket-cli
# Based on https://github.com/Typeform/gitleaks-config
# https://github.com/gitleaks/gitleaks
title = "gitleaks config for bitbucket-cli"
# Require gitleaks v8.25.0+ for compatibility with default rules
minVersion = "v8.25.0"
[extend]
# Extend the base config with all default rules
useDefault = true
[[allowlists]]
description = "Allowlist for test fixtures and known false positives"
regexTarget = "secret"
# Paths to exclude from scanning
# NOTE: Broad exclusions should be reviewed periodically. Consider using
# .gitleaksignore with fingerprints for specific false positives instead.
paths = [
'''\.gitleaks\.toml$''',
'''(.*?)(jpg|gif|doc|pdf|bin|png|svg)$''',
'''testdata\/''',
'''fixtures\/''',
'''go\.(mod|sum)$''',
'''vendor\.json''',
'''Gopkg\.(lock|toml)''',
'''package-lock\.json''',
'''package\.json''',
'''yarn\.lock''',
'''node_modules\/''',
'''vendor\/''',
]
# Common test values and patterns that are not real secrets
# IMPORTANT: Avoid adding real-looking passwords here. Use path exclusions
# or .gitleaksignore fingerprints for specific files instead.
regexes = [
'''test-api-key''',
'''fake-token''',
'''dummy-secret''',
'''example\.com''',
'''localhost''',
'''127\.0\.0\.1''',
'''192\.168\..*''',
'''0\.0\.0\.0''',
]
# Allow dependency lock files and generated content
stopwords = [
"EXAMPLE",
"example",
"CHANGEME",
"changeme",
"PLACEHOLDER",
"placeholder",
]
# ============================================================================
# Custom rules for Bitbucket-specific secrets
# ============================================================================
[[rules]]
id = "bitbucket-app-password"
description = "Bitbucket App Password"
regex = '''(?i)(bitbucket[_-]?(app[_-]?)?(password|token))\s*[:=]\s*['"]?([A-Za-z0-9]{20,})['"]?'''
entropy = 3.5
secretGroup = 4
keywords = ["bitbucket", "password", "token", "app"]
[[rules]]
id = "bitbucket-credentials"
description = "Potential Bitbucket credentials in config"
regex = '''(?i)(bitbucket[_-]?(password|user|secret))\s*[:=]\s*['"]?([^'"\s]{8,})['"]?'''
secretGroup = 3
# ============================================================================
# Generic credential detection rules (from Typeform gitleaks-config)
# https://github.com/Typeform/gitleaks-config
# ============================================================================
[[rules]]
description = "Authorization Bearer tokens"
id = "authorization-bearer-token"
regex = '''(?i)Bearer(?:\s)+(\S{8,})'''
secretGroup = 1
entropy = 3.8
tags = ["key", "HTTP", "bearer"]
[[rules]]
description = "Hardcoded credentials in Go files"
id = "credentials-go"
path = '''(.*?)\.go$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:\w|\s*?)(?:=|:=)(?:\s*?)["'`](.{4,120}?)["'`]'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "go"]
[[rules]]
description = "Hardcoded credentials in JavaScript or TypeScript files"
id = "credentials-javascript"
path = '''(.*?)\.(?:j|t)s$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:\w|\s*?)(?:=){1}(?:\s{0,10})["'`](.*?)["'`]'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "js"]
[[rules]]
description = "Hardcoded credentials in Python files"
id = "credentials-python"
path = '''(.*?)\.py$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:.{0,20})(?:=){1}(?:\s)*?["'](.{4,120})["']'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "python"]
[[rules]]
description = "Hardcoded credentials in Shell scripts"
id = "credentials-shell"
path = '''(.*?)\.(sh|bash|zsh)$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:.{0,20})(?:=){1}(?:\s)*?["']?(.{4,120})["']?'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "shell"]
[[rules]]
description = "Hardcoded credentials in YAML files (quoted)"
id = "credentials-yaml-quoted"
path = '''(.*?)\.ya?ml$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:.{0,20})(?::){1}(?:\s{0,10})(?:["'](.{4,120})["'])'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "yaml"]
[[rules.allowlists]]
description = "Skip YAML variables and encrypted values"
regexes = [
'''\${(?:.)+}''',
'''{{(?:.)*?}}''',
'''ENC\[AES256_GCM,data:''',
]
[[rules]]
description = "Hardcoded credentials in YAML files (unquoted)"
id = "credentials-yaml-unquoted"
path = '''(.*?)\.ya?ml$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:\w|\s*?)(?::){1}(?:\s*?)((?:\w|\S)+)'''
secretGroup = 1
entropy = 3.5
tags = ["credentials", "hardcoded", "yaml"]
[[rules.allowlists]]
description = "Skip YAML variables and template values"
regexes = [
''':$''',
'''\${(?:.)+}''',
'''{{(?:.)*?}}''',
'''={{$''',
]
[[rules]]
description = "Hardcoded credentials in Terraform files"
id = "credentials-terraform"
path = '''(.*?)\.tf$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token)(?:.{0,20})(?:=){1}(?:\s)*?"(.{4,120})"'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "terraform"]
[[rules.allowlists]]
description = "Skip variable substitution"
regexes = [
'''\${(?:.)*?}''',
]
# ============================================================================
# Database connection strings
# ============================================================================
[[rules]]
id = "mysql-connection-string"
description = "MySQL connection string with credentials"
regex = '''mysql://([^:]+):([^@]+)@[^/]+/'''
secretGroup = 2
tags = ["database", "mysql"]
[[rules]]
id = "postgres-connection-string"
description = "PostgreSQL connection string with credentials"
regex = '''postgres(?:ql)?://([^:]+):([^@]+)@[^/]+/'''
secretGroup = 2
tags = ["database", "postgres"]
[[rules]]
id = "mongodb-connection-string"
description = "MongoDB connection string with credentials"
regex = '''mongodb(?:\+srv)?://([^:]+):([^@]+)@'''
secretGroup = 2
tags = ["database", "mongodb"]
# ============================================================================
# Additional rules based on GitGuardian findings
# ============================================================================
[[rules]]
id = "generic-auth-tuple"
description = "Generic authentication tuple (user:password@host)"
# Matches user:pass@ patterns not covered by specific DB rules
regex = '''([a-zA-Z0-9_-]+):([^@\s]{8,})@[a-zA-Z0-9.-]+'''
secretGroup = 2
entropy = 2.5
tags = ["credentials", "auth-tuple"]
[[rules.allowlists]]
description = "Skip email-like patterns and known safe patterns"
regexes = [
'''@gmail\.com''',
'''@github\.com''',
'''@example\.com''',
]
[[rules]]
description = "Hardcoded credentials in JSON files"
id = "credentials-json"
path = '''(.*?)\.json$'''
regex = '''(?i)["'](?:secret|key|password|pwd|pass|token|api_key|apikey|auth)["']\s*:\s*["']([^"']{8,})["']'''
secretGroup = 1
entropy = 3
tags = ["credentials", "hardcoded", "json"]
[[rules.allowlists]]
description = "Skip package manifests and lock files"
paths = [
'''package\.json$''',
'''package-lock\.json$''',
'''composer\.json$''',
'''tsconfig\.json$''',
]
[[rules]]
description = "Hardcoded credentials in .env files"
id = "credentials-env"
path = '''(.*?)\.env(\..*)?$'''
regex = '''(?i)(?:secret|key|password|pwd|pass|token|api_key|apikey)(?:\w*)=["']?([^"'\s\n]{8,})["']?'''
secretGroup = 1
entropy = 2.5
tags = ["credentials", "hardcoded", "env"]
[[rules.allowlists]]
description = "Skip example env files and placeholders"
paths = [
'''\.env\.example$''',
'''\.env\.sample$''',
'''\.env\.template$''',
]
regexes = [
'''CHANGEME''',
'''PLACEHOLDER''',
'''your-.*-here''',
'''<.*>''',
]
[[rules]]
id = "fernet-key"
description = "Fernet encryption key (base64 encoded)"
# Fernet keys are 32 bytes = 44 chars base64 ending in =
regex = '''(?i)(?:fernet[_-]?key|FERNET_KEY)\s*[:=]\s*["']?([A-Za-z0-9+/]{43}=)["']?'''
secretGroup = 1
tags = ["credentials", "encryption", "fernet"]
[[rules]]
id = "jwt-token"
description = "JSON Web Token"
# JWT format: base64.base64.base64
regex = '''eyJ[A-Za-z0-9_-]*\.eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*'''
tags = ["credentials", "jwt"]