@@ -178,21 +178,39 @@ func TestAWSSecretKeyPattern(t *testing.T) {
178178 wantExample bool
179179 }{
180180 {
181- name : "example secret key" ,
181+ name : "standalone secret key - no context, should not match " ,
182182 input : "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" ,
183+ wantMatch : false , // Now requires context
184+ wantExample : false ,
185+ },
186+ {
187+ name : "secret key with aws_secret_access_key context" ,
188+ input : `aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` ,
183189 wantMatch : true ,
184190 wantExample : true ,
185191 },
186192 {
187- name : "secret key in context" ,
188- input : `aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` ,
193+ name : "secret key with AWS_SECRET_KEY context" ,
194+ input : `AWS_SECRET_KEY=" wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" ` ,
189195 wantMatch : true ,
190196 wantExample : true ,
191197 },
192198 {
193- name : "random 40 char base64-like " ,
194- input : "abcdefghij1234567890ABCDEFGHIJ1234567890" ,
199+ name : "secret key with secretAccessKey JSON context " ,
200+ input : `"secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"` ,
195201 wantMatch : true ,
202+ wantExample : true ,
203+ },
204+ {
205+ name : "random 40 char base64-like without context - no match" ,
206+ input : "abcdefghij1234567890ABCDEFGHIJ1234567890" ,
207+ wantMatch : false , // Now requires context
208+ wantExample : false ,
209+ },
210+ {
211+ name : "RSA private key content - should not match" ,
212+ input : "MIIEpAIBAAKCAQEA0Z3VS5JJcds3xfn/ygWyF8Pb" ,
213+ wantMatch : false , // No AWS context
196214 wantExample : false ,
197215 },
198216 {
@@ -325,23 +343,33 @@ func TestAzureClientSecretPattern(t *testing.T) {
325343 wantMatch bool
326344 }{
327345 {
328- name : "Azure client secret format 1 " ,
346+ name : "standalone secret - no context, should not match " ,
329347 input : "7c9~abcdefghijklmnopqrstuvwxyz1234" ,
330- wantMatch : true ,
348+ wantMatch : false , // Now requires context
331349 },
332350 {
333- name : "Azure client secret format 2" ,
351+ name : "standalone secret format 2 - no context, should not match " ,
334352 input : "abc.defghijklmnopqrstuvwxyz123456~" ,
335- wantMatch : true ,
353+ wantMatch : false , // Now requires context
336354 },
337355 {
338- name : "Azure client secret in config " ,
356+ name : "Azure client secret with AZURE_CLIENT_SECRET context " ,
339357 input : `AZURE_CLIENT_SECRET=7c9~abcdefghijklmnopqrstuvwxyz1234` ,
340358 wantMatch : true ,
341359 },
342360 {
343- name : "too short" ,
344- input : "7c9~abc" ,
361+ name : "Azure client secret with client_secret context" ,
362+ input : `client_secret: "7c9~abcdefghijklmnopqrstuvwxyz1234"` ,
363+ wantMatch : true ,
364+ },
365+ {
366+ name : "Azure client secret with clientSecret JSON context" ,
367+ input : `"clientSecret": "abc.defghijklmnopqrstuvwxyz123456~"` ,
368+ wantMatch : true ,
369+ },
370+ {
371+ name : "too short even with context" ,
372+ input : `AZURE_CLIENT_SECRET=7c9~abc` ,
345373 wantMatch : false ,
346374 },
347375 }
0 commit comments