[fix] - Sonarcloud detector (#3982)
Lint / golangci-lint (push) Waiting to run
Lint / semgrep (push) Waiting to run
Release / Release (push) Waiting to run
Scan for secrets / test (push) Waiting to run
Test / test (push) Waiting to run
Test / test-community (push) Waiting to run

This commit is contained in:
Kay Agahd
2025-03-18 12:25:56 -07:00
committed by GitHub
parent ef3a714619
commit ded5f45b92
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -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.
@@ -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 {