Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
[fix] - Sonarcloud detector (#3982)
Kay Agahdded5f45b92c0
diff --git a/pkg/detectors/sonarcloud/sonarcloud.go b/pkg/detectors/sonarcloud/sonarcloud.goindex 0cebf3664..dfc88b106 100644--- a/pkg/detectors/sonarcloud/sonarcloud.go+++ b/pkg/detectors/sonarcloud/sonarcloud.go@@ -21,7 +21,7 @@ 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{"sonar"}) + `\b([0-9a-z]{40})\b`)+ keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sonar"}) + `(?:^|[^@])\b([0-9a-z]{40})\b`))// Keywords are used for efficiently pre-filtering chunks.diff --git a/pkg/detectors/sonarcloud/sonarcloud_test.go b/pkg/detectors/sonarcloud/sonarcloud_test.goindex 142b34352..9167a1003 100644--- a/pkg/detectors/sonarcloud/sonarcloud_test.go+++ b/pkg/detectors/sonarcloud/sonarcloud_test.go@@ -45,6 +45,11 @@ func TestSonarCloud_Pattern(t *testing.T) {input: fmt.Sprintf("%s = '%s'", keyword, invalidPattern),want: []string{},},+ {+ name: "invalid pattern - token directly preceded by @",+ input: fmt.Sprintf("%s token = '@%s'", keyword, validPattern),+ want: []string{},+ },}for _, test := range tests {