Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
fix regex pattern for confluent detector (#778)
Apoorv Munshi33ff9178e453
diff --git a/pkg/detectors/confluent/confluent.go b/pkg/detectors/confluent/confluent.goindex c21edd7dc..685f08811 100644--- a/pkg/detectors/confluent/confluent.go+++ b/pkg/detectors/confluent/confluent.go@@ -22,8 +22,8 @@ var (client = common.SaneHttpClient()// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.- keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"confluent"}) + `\b([a-zA-Z-0-9]{16})\b`)- secretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"confluent"}) + `\b([a-zA-Z-0-9]{64})\b`)+ keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"confluent"}) + `\b([a-zA-Z0-9]{16})\b`)+ secretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"confluent"}) + `\b([a-zA-Z0-9\+\/]{64})\b`))// Keywords are used for efficiently pre-filtering chunks.@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (resultif verify {data := fmt.Sprintf("%s:%s", resMatch, resSecret)sEnc := b64.StdEncoding.EncodeToString([]byte(data))- req, err := http.NewRequestWithContext(ctx, "GET", "https://api.telemetry.confluent.cloud/v2/metrics/cloud/descriptors/resources", nil)+ req, err := http.NewRequestWithContext(ctx, "GET", "https://api.confluent.cloud/iam/v2/api-keys/"+resMatch, nil)if err != nil {continue}@@ -72,7 +72,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results1.Verified = true} else {// This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key.- if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) {+ if detectors.IsKnownFalsePositive(resSecret, detectors.DefaultFalsePositives, true) {continue}}