Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
(fix) Leading = in gitlab v1 token (#4156)
Abdul Basit15fd312ca708
diff --git a/pkg/detectors/gitlab/v1/gitlab.go b/pkg/detectors/gitlab/v1/gitlab.goindex d8a9af03a..7eb5e525e 100644--- a/pkg/detectors/gitlab/v1/gitlab.go+++ b/pkg/detectors/gitlab/v1/gitlab.go@@ -33,7 +33,7 @@ func (Scanner) CloudEndpoint() string { return "https://gitlab.com" }var (defaultClient = common.SaneHttpClient()- keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"gitlab"}) + `\b([a-zA-Z0-9\-=_]{20,22})\b`)+ keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"gitlab"}) + `\b([a-zA-Z0-9][a-zA-Z0-9\-=_]{19,21})\b`)BlockedUserMessage = "403 Forbidden - Your account has been blocked")diff --git a/pkg/detectors/gitlab/v1/gitlab_v1_test.go b/pkg/detectors/gitlab/v1/gitlab_v1_test.goindex 3b19e5dee..148642ac0 100644--- a/pkg/detectors/gitlab/v1/gitlab_v1_test.go+++ b/pkg/detectors/gitlab/v1/gitlab_v1_test.go@@ -25,7 +25,9 @@ var ("method": "GET","deprecated": false}]`- secret = "oXCt4JT2wf1_WlZl2OVG"+ secret = "oXCt4JT2wf1_WlZl2OVG"+ validPattern2 = "GITLAB_TOKEN=ABc123456789dEFghIJK"+ secret2 = "ABc123456789dEFghIJK")func TestGitLab_Pattern(t *testing.T) {@@ -42,6 +44,11 @@ func TestGitLab_Pattern(t *testing.T) {input: validPattern,want: []string{secret},},+ {+ name: "valid pattern (with = before secret)",+ input: validPattern2,+ want: []string{secret2},+ },}for _, test := range tests {