Skip to content

Commit 15fd312

Browse files
authored
(fix) Leading = in gitlab v1 token (#4156)
* gitlab key cannot have = as first character * remove - and _ for first character * fix: remove extra /
1 parent 542efee commit 15fd312

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/detectors/gitlab/v1/gitlab.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (Scanner) CloudEndpoint() string { return "https://gitlab.com" }
3333

3434
var (
3535
defaultClient = common.SaneHttpClient()
36-
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"gitlab"}) + `\b([a-zA-Z0-9\-=_]{20,22})\b`)
36+
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"gitlab"}) + `\b([a-zA-Z0-9][a-zA-Z0-9\-=_]{19,21})\b`)
3737

3838
BlockedUserMessage = "403 Forbidden - Your account has been blocked"
3939
)

pkg/detectors/gitlab/v1/gitlab_v1_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ var (
2525
"method": "GET",
2626
"deprecated": false
2727
}]`
28-
secret = "oXCt4JT2wf1_WlZl2OVG"
28+
secret = "oXCt4JT2wf1_WlZl2OVG"
29+
validPattern2 = "GITLAB_TOKEN=ABc123456789dEFghIJK"
30+
secret2 = "ABc123456789dEFghIJK"
2931
)
3032

3133
func TestGitLab_Pattern(t *testing.T) {
@@ -42,6 +44,11 @@ func TestGitLab_Pattern(t *testing.T) {
4244
input: validPattern,
4345
want: []string{secret},
4446
},
47+
{
48+
name: "valid pattern (with = before secret)",
49+
input: validPattern2,
50+
want: []string{secret2},
51+
},
4552
}
4653

4754
for _, test := range tests {

0 commit comments

Comments
 (0)