Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
[Update] Fixed the Return of the GCP Detector (#3905)
Nabeel Alamec42f4437c8d
diff --git a/pkg/detectors/gcp/gcp.go b/pkg/detectors/gcp/gcp.goindex 5785974f5..85cefa57f 100644--- a/pkg/detectors/gcp/gcp.go+++ b/pkg/detectors/gcp/gcp.go@@ -123,15 +123,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result}if verify {- credentials, err := google.CredentialsFromJSON(ctx, credBytes, "https://www.googleapis.com/auth/cloud-platform")- if err != nil {- continue- }-- if _, err = credentials.TokenSource.Token(); err != nil {- continue- }- result.Verified = true+ isVerified, verificationErr := verifyMatch(ctx, credBytes)+ result.Verified = isVerified+ result.SetVerificationError(verificationErr, match)}results = append(results, result)@@ -140,6 +134,18 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (resultreturn}+func verifyMatch(ctx context.Context, credBytes []byte) (bool, error) {+ credentials, err := google.CredentialsFromJSON(ctx, credBytes, "https://www.googleapis.com/auth/cloud-platform")+ if err != nil {+ return false, err+ }++ if _, err = credentials.TokenSource.Token(); err != nil {+ return false, err+ }+ return true, nil+}+func (s Scanner) IsFalsePositive(_ detectors.Result) (bool, string) {return false, ""}