@@ -74,10 +74,10 @@ var (
74
74
75
75
// Reusable regex patterns
76
76
const (
77
- quote = `["']?`
78
- connect = `\s*(:|=>|=)?\s*`
79
- startSecret = `(^| \s+)`
80
- endSecret = `[.,]?(\s+|$)`
77
+ quote = `["']?`
78
+ connect = `\s*(:|=>|=)?\s*`
79
+ endSecret = `[.,]?( \s+|$ )`
80
+ startWord = "([^0-9a-zA-Z]|^)"
81
81
82
82
aws = `aws_?`
83
83
)
@@ -103,7 +103,7 @@ var builtinRules = []Rule{
103
103
Category : CategoryAWS ,
104
104
Severity : "CRITICAL" ,
105
105
Title : "AWS Access Key ID" ,
106
- Regex : MustCompile (fmt .Sprintf (`%s (?P<secret>(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})%s%s` , quote , quote , endSecret )),
106
+ Regex : MustCompileWithoutWordPrefix (fmt .Sprintf (`(?P<secret>(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})%s%s` , quote , endSecret )),
107
107
SecretGroupName : "secret" ,
108
108
Keywords : []string {"AKIA" , "AGPA" , "AIDA" , "AROA" , "AIPA" , "ANPA" , "ANVA" , "ASIA" },
109
109
},
@@ -112,41 +112,45 @@ var builtinRules = []Rule{
112
112
Category : CategoryAWS ,
113
113
Severity : "CRITICAL" ,
114
114
Title : "AWS Secret Access Key" ,
115
- Regex : MustCompile (fmt .Sprintf (`(?i)%s%s%s (sec(ret)?)?_?(access)?_?key%s%s%s(?P<secret>[A-Za-z0-9\/\+=]{40})%s%s` , startSecret , quote , aws , quote , connect , quote , quote , endSecret )),
115
+ Regex : MustCompile (fmt .Sprintf (`(?i)%s%s(sec(ret)?)?_?(access)?_?key%s%s%s(?P<secret>[A-Za-z0-9\/\+=]{40})%s%s` , quote , aws , quote , connect , quote , quote , endSecret )),
116
116
SecretGroupName : "secret" ,
117
117
Keywords : []string {"key" },
118
118
},
119
119
{
120
- ID : "github-pat" ,
121
- Category : CategoryGitHub ,
122
- Title : "GitHub Personal Access Token" ,
123
- Severity : "CRITICAL" ,
124
- Regex : MustCompile (`ghp_[0-9a-zA-Z]{36}` ),
125
- Keywords : []string {"ghp_" },
120
+ ID : "github-pat" ,
121
+ Category : CategoryGitHub ,
122
+ Title : "GitHub Personal Access Token" ,
123
+ Severity : "CRITICAL" ,
124
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>ghp_[0-9a-zA-Z]{36}` ),
125
+ SecretGroupName : "secret" ,
126
+ Keywords : []string {"ghp_" },
126
127
},
127
128
{
128
- ID : "github-oauth" ,
129
- Category : CategoryGitHub ,
130
- Title : "GitHub OAuth Access Token" ,
131
- Severity : "CRITICAL" ,
132
- Regex : MustCompile (`gho_[0-9a-zA-Z]{36}` ),
133
- Keywords : []string {"gho_" },
129
+ ID : "github-oauth" ,
130
+ Category : CategoryGitHub ,
131
+ Title : "GitHub OAuth Access Token" ,
132
+ Severity : "CRITICAL" ,
133
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>gho_[0-9a-zA-Z]{36}` ),
134
+ SecretGroupName : "secret" ,
135
+ Keywords : []string {"gho_" },
134
136
},
135
137
{
136
- ID : "github-app-token" ,
137
- Category : CategoryGitHub ,
138
- Title : "GitHub App Token" ,
139
- Severity : "CRITICAL" ,
140
- Regex : MustCompile (`(ghu|ghs)_[0-9a-zA-Z]{36}` ),
141
- Keywords : []string {"ghu_" , "ghs_" },
138
+ ID : "github-app-token" ,
139
+ Category : CategoryGitHub ,
140
+ Title : "GitHub App Token" ,
141
+ Severity : "CRITICAL" ,
142
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>(ghu|ghs)_[0-9a-zA-Z]{36}` ),
143
+ SecretGroupName : "secret" ,
144
+ Keywords : []string {"ghu_" , "ghs_" },
142
145
},
143
146
{
144
- ID : "github-refresh-token" ,
145
- Category : CategoryGitHub ,
146
- Title : "GitHub Refresh Token" ,
147
- Severity : "CRITICAL" ,
148
- Regex : MustCompile (`ghr_[0-9a-zA-Z]{76}` ),
149
- Keywords : []string {"ghr_" },
147
+ ID : "github-refresh-token" ,
148
+ Category : CategoryGitHub ,
149
+ Title : "GitHub Refresh Token" ,
150
+ Severity : "CRITICAL" ,
151
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>ghr_[0-9a-zA-Z]{76}` ),
152
+ SecretGroupName : "secret" ,
153
+ Keywords : []string {"ghr_" },
150
154
},
151
155
{
152
156
ID : "github-fine-grained-pat" ,
@@ -157,21 +161,23 @@ var builtinRules = []Rule{
157
161
Keywords : []string {"github_pat_" },
158
162
},
159
163
{
160
- ID : "gitlab-pat" ,
161
- Category : CategoryGitLab ,
162
- Title : "GitLab Personal Access Token" ,
163
- Severity : "CRITICAL" ,
164
- Regex : MustCompile (`glpat-[0-9a-zA-Z\-\_]{20}` ),
165
- Keywords : []string {"glpat-" },
164
+ ID : "gitlab-pat" ,
165
+ Category : CategoryGitLab ,
166
+ Title : "GitLab Personal Access Token" ,
167
+ Severity : "CRITICAL" ,
168
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>glpat-[0-9a-zA-Z\-\_]{20}` ),
169
+ SecretGroupName : "secret" ,
170
+ Keywords : []string {"glpat-" },
166
171
},
167
172
{
168
173
// cf. https://huggingface.co/docs/hub/en/security-tokens
169
- ID : "hugging-face-access-token" ,
170
- Category : CategoryHuggingFace ,
171
- Severity : "CRITICAL" ,
172
- Title : "Hugging Face Access Token" ,
173
- Regex : MustCompile (`hf_[A-Za-z0-9]{34,40}` ),
174
- Keywords : []string {"hf_" },
174
+ ID : "hugging-face-access-token" ,
175
+ Category : CategoryHuggingFace ,
176
+ Severity : "CRITICAL" ,
177
+ Title : "Hugging Face Access Token" ,
178
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>hf_[A-Za-z0-9]{34,40}` ),
179
+ SecretGroupName : "secret" ,
180
+ Keywords : []string {"hf_" },
175
181
},
176
182
{
177
183
ID : "private-key" ,
@@ -191,28 +197,31 @@ var builtinRules = []Rule{
191
197
Keywords : []string {"shpss_" , "shpat_" , "shpca_" , "shppa_" },
192
198
},
193
199
{
194
- ID : "slack-access-token" ,
195
- Category : CategorySlack ,
196
- Title : "Slack token" ,
197
- Severity : "HIGH" ,
198
- Regex : MustCompile (`xox[baprs]-([0-9a-zA-Z]{10,48})` ),
199
- Keywords : []string {"xoxb-" , "xoxa-" , "xoxp-" , "xoxr-" , "xoxs-" },
200
+ ID : "slack-access-token" ,
201
+ Category : CategorySlack ,
202
+ Title : "Slack token" ,
203
+ Severity : "HIGH" ,
204
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>xox[baprs]-([0-9a-zA-Z]{10,48})` ),
205
+ SecretGroupName : "secret" ,
206
+ Keywords : []string {"xoxb-" , "xoxa-" , "xoxp-" , "xoxr-" , "xoxs-" },
200
207
},
201
208
{
202
- ID : "stripe-publishable-token" ,
203
- Category : CategoryStripe ,
204
- Title : "Stripe Publishable Key" ,
205
- Severity : "LOW" ,
206
- Regex : MustCompile (`(?i)pk_(test|live)_[0-9a-z]{10,32}` ),
207
- Keywords : []string {"pk_test_" , "pk_live_" },
209
+ ID : "stripe-publishable-token" ,
210
+ Category : CategoryStripe ,
211
+ Title : "Stripe Publishable Key" ,
212
+ Severity : "LOW" ,
213
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>(?i)pk_(test|live)_[0-9a-z]{10,32}` ),
214
+ SecretGroupName : "secret" ,
215
+ Keywords : []string {"pk_test_" , "pk_live_" },
208
216
},
209
217
{
210
- ID : "stripe-secret-token" ,
211
- Category : CategoryStripe ,
212
- Title : "Stripe Secret Key" ,
213
- Severity : "CRITICAL" ,
214
- Regex : MustCompile (`(?i)sk_(test|live)_[0-9a-z]{10,32}` ),
215
- Keywords : []string {"sk_test_" , "sk_live_" },
218
+ ID : "stripe-secret-token" ,
219
+ Category : CategoryStripe ,
220
+ Title : "Stripe Secret Key" ,
221
+ Severity : "CRITICAL" ,
222
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>(?i)sk_(test|live)_[0-9a-z]{10,32}` ),
223
+ SecretGroupName : "secret" ,
224
+ Keywords : []string {"sk_test_" , "sk_live_" },
216
225
},
217
226
{
218
227
ID : "pypi-upload-token" ,
@@ -506,20 +515,22 @@ var builtinRules = []Rule{
506
515
Keywords : []string {"finicity" },
507
516
},
508
517
{
509
- ID : "flutterwave-public-key" ,
510
- Category : CategoryFlutterwave ,
511
- Title : "Flutterwave public/secret key" ,
512
- Severity : "MEDIUM" ,
513
- Regex : MustCompile (`FLW(PUB|SEC)K_TEST-(?i)[a-h0-9]{32}-X` ),
514
- Keywords : []string {"FLWSECK_TEST-" , "FLWPUBK_TEST-" },
518
+ ID : "flutterwave-public-key" ,
519
+ Category : CategoryFlutterwave ,
520
+ Title : "Flutterwave public/secret key" ,
521
+ Severity : "MEDIUM" ,
522
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>FLW(PUB|SEC)K_TEST-(?i)[a-h0-9]{32}-X` ),
523
+ SecretGroupName : "secret" ,
524
+ Keywords : []string {"FLWSECK_TEST-" , "FLWPUBK_TEST-" },
515
525
},
516
526
{
517
- ID : "flutterwave-enc-key" ,
518
- Category : CategoryFlutterwave ,
519
- Title : "Flutterwave encrypted key" ,
520
- Severity : "MEDIUM" ,
521
- Regex : MustCompile (`FLWSECK_TEST[a-h0-9]{12}` ),
522
- Keywords : []string {"FLWSECK_TEST" },
527
+ ID : "flutterwave-enc-key" ,
528
+ Category : CategoryFlutterwave ,
529
+ Title : "Flutterwave encrypted key" ,
530
+ Severity : "MEDIUM" ,
531
+ Regex : MustCompileWithoutWordPrefix (`?P<secret>FLWSECK_TEST[a-h0-9]{12}` ),
532
+ SecretGroupName : "secret" ,
533
+ Keywords : []string {"FLWSECK_TEST" },
523
534
},
524
535
{
525
536
ID : "frameio-api-token" ,
0 commit comments