@@ -71,6 +71,13 @@ func (s scanner) Keywords() []string {
71
71
}
72
72
}
73
73
74
+ func (s scanner ) getClient () * http.Client {
75
+ if s .verificationClient == nil {
76
+ s .verificationClient = defaultVerificationClient
77
+ }
78
+ return s .verificationClient
79
+ }
80
+
74
81
// FromData will find and optionally verify AWS secrets in a given set of bytes.
75
82
func (s scanner ) FromData (ctx context.Context , verify bool , data []byte ) (results []detectors.Result , err error ) {
76
83
logger := logContext .AddLogger (ctx ).Logger ().WithName ("aws" )
@@ -201,6 +208,7 @@ func (s scanner) verifyMatch(ctx context.Context, resIDMatch, resSecretMatch str
201
208
// Prep AWS Creds for STS
202
209
cfg , err := config .LoadDefaultConfig (ctx ,
203
210
config .WithRegion (region ),
211
+ config .WithHTTPClient (s .getClient ()),
204
212
config .WithCredentialsProvider (
205
213
credentials .NewStaticCredentialsProvider (resIDMatch , resSecretMatch , "" ),
206
214
),
@@ -214,7 +222,7 @@ func (s scanner) verifyMatch(ctx context.Context, resIDMatch, resSecretMatch str
214
222
// Make the GetCallerIdentity API call
215
223
resp , err := stsClient .GetCallerIdentity (ctx , & sts.GetCallerIdentityInput {})
216
224
if err != nil {
217
- if strings .Contains (err .Error (), "StatusCode: 403" ) {
225
+ if strings .Contains (err .Error (), "StatusCode: 403" ) || strings . Contains ( err . Error (), "InvalidClientTokenId" ) {
218
226
return false , nil , nil
219
227
}
220
228
return false , nil , fmt .Errorf ("request returned unexpected error: %s" , err .Error ())
0 commit comments