Skip to content

Commit 699257c

Browse files
Merge branch 'main' into update/oss-136-storyblok-detector
2 parents 4093af0 + ded5f45 commit 699257c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/detectors/sonarcloud/sonarcloud.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121
client = common.SaneHttpClient()
2222

2323
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
24-
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sonar"}) + `\b([0-9a-z]{40})\b`)
24+
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sonar"}) + `(?:^|[^@])\b([0-9a-z]{40})\b`)
2525
)
2626

2727
// Keywords are used for efficiently pre-filtering chunks.

pkg/detectors/sonarcloud/sonarcloud_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ func TestSonarCloud_Pattern(t *testing.T) {
4545
input: fmt.Sprintf("%s = '%s'", keyword, invalidPattern),
4646
want: []string{},
4747
},
48+
{
49+
name: "invalid pattern - token directly preceded by @",
50+
input: fmt.Sprintf("%s token = '@%s'", keyword, validPattern),
51+
want: []string{},
52+
},
4853
}
4954

5055
for _, test := range tests {

0 commit comments

Comments
 (0)