@@ -104,6 +104,41 @@ func InitRules(confidenceFilter []string) {
104104func AppendPipeleekRules (rules []types.PatternElement ) []types.PatternElement {
105105 customRules := []types.PatternElement {}
106106 customRules = append (customRules , types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Predefined Environment Variable" , Regex : `(GITLAB_USER_ID|KUBECONFIG|CI_SERVER_TLS_KEY_FILE|CI_REPOSITORY_URL|CI_REGISTRY_PASSWORD|DOCKER_AUTH_CONFIG)=.*` , Confidence : "medium" }})
107+
108+ // Built-in rules for GitLab token types to ensure detection regardless of
109+ // TruffleHog verification (which only verifies against gitlab.com and
110+ // therefore misses tokens for self-hosted GitLab instances).
111+ customRules = append (customRules ,
112+ // https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/gitlab/v2/gitlab_v2.go
113+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Personal Access Token v2" , Regex : `glpat-[a-zA-Z0-9\-=_]{20,22}` , Confidence : "high" }},
114+ // https://github.com/trufflesecurity/trufflehog/blob/afd5336caad0f61da51750ffe39869974b27b0db/pkg/detectors/gitlab/v3/gitlab_v3.go#L34
115+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Personal Access Token v3" , Regex : `\b(glpat-[a-zA-Z0-9\-=_]{27,300}.[0-9a-z]{2}.[a-z0-9]{9})\b` , Confidence : "high" }},
116+ // https://github.com/gitlabhq/gitlabhq/blob/master/app/models/ci/trigger.rb
117+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Pipeline Trigger Token" , Regex : `glptt-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
118+ // https://github.com/gitlabhq/gitlabhq/blob/master/app/models/ci/runner.rb (CREATED_RUNNER_TOKEN_PREFIX)
119+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Runner Authentication Token" , Regex : `glrt-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
120+ // https://github.com/gitlabhq/gitlabhq/blob/master/app/models/ci/runner.rb (REGISTRATION_RUNNER_TOKEN_PREFIX)
121+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Runner Registration Token" , Regex : `glrtr-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
122+ // https://github.com/gitlabhq/gitlabhq/blob/master/app/models/deploy_token.rb
123+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Deploy Token" , Regex : `gldt-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
124+ // https://github.com/gitlabhq/gitlabhq/blob/master/app/models/ci/build.rb
125+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - CI Build Token" , Regex : `glcbt-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
126+ // https://github.com/gitlabhq/gitlabhq/blob/master/spec/lib/authn/tokens/oauth_application_secret_spec.rb
127+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - OAuth Application Secret" , Regex : `gloas-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
128+ // https://docs.gitlab.com/security/token_overview/
129+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - SCIM/OAuth Access Token" , Regex : `glsoat-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
130+ // https://docs.gitlab.com/security/token_overview/
131+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Feed Token" , Regex : `glft-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
132+ // https://docs.gitlab.com/security/token_overview/
133+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Incoming Mail Token" , Regex : `glimt-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
134+ // https://docs.gitlab.com/security/token_overview/
135+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Feature Flags Client Token" , Regex : `glffct-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
136+ // https://docs.gitlab.com/security/token_overview/
137+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Agent for Kubernetes Token" , Regex : `glagent-[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
138+ // https://github.com/gitlabhq/gitlabhq/blob/master/app/models/concerns/runners_token_prefixable.rb
139+ types.PatternElement {Pattern : types.PatternPattern {Name : "Gitlab - Runner Token (Legacy)" , Regex : `GR1348941[a-zA-Z0-9\-=_]{20,}` , Confidence : "high" }},
140+ )
141+
107142 return slices .Concat (rules , customRules )
108143}
109144
0 commit comments