Skip to content

Commit

Permalink
Add missing GitLab token patterns (gitleaks#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch authored Jan 22, 2023
1 parent e002920 commit afdccad
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/generate/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func main() {
configRules = append(configRules, rules.GitHubOauth())
configRules = append(configRules, rules.GitHubApp())
configRules = append(configRules, rules.GitHubRefresh())
configRules = append(configRules, rules.Gitlab())
configRules = append(configRules, rules.GitlabPat())
configRules = append(configRules, rules.GitlabPipelineTriggerToken())
configRules = append(configRules, rules.GitlabRunnerRegistrationToken())
configRules = append(configRules, rules.GitterAccessToken())
configRules = append(configRules, rules.GrafanaApiKey())
configRules = append(configRules, rules.GrafanaCloudApiToken())
Expand Down
34 changes: 33 additions & 1 deletion cmd/generate/config/rules/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/zricethezav/gitleaks/v8/config"
)

func Gitlab() *config.Rule {
func GitlabPat() *config.Rule {
// define rule
r := config.Rule{
Description: "GitLab Personal Access Token",
Expand All @@ -22,3 +22,35 @@ func Gitlab() *config.Rule {
}
return validate(r, tps, nil)
}

func GitlabPipelineTriggerToken() *config.Rule {
// define rule
r := config.Rule{
Description: "GitLab Pipeline Trigger Token",
RuleID: "gitlab-ptt",
Regex: regexp.MustCompile(`glptt-[0-9a-f]{40}`),
Keywords: []string{"glptt-"},
}

// validate
tps := []string{
generateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(hex("40"))),
}
return validate(r, tps, nil)
}

func GitlabRunnerRegistrationToken() *config.Rule {
// define rule
r := config.Rule{
Description: "GitLab Runner Registration Token",
RuleID: "gitlab-rrt",
Regex: regexp.MustCompile(`GR1348941[0-9a-zA-Z\-\_]{20}`),
Keywords: []string{"GR1348941"},
}

// validate
tps := []string{
generateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(alphaNumeric("20"))),
}
return validate(r, tps, nil)
}
16 changes: 16 additions & 0 deletions config/gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,22 @@ keywords = [
"glpat-",
]

[[rules]]
description = "GitLab Pipeline Trigger Token"
id = "gitlab-ptt"
regex = '''glptt-[0-9a-f]{40}'''
keywords = [
"glptt-",
]

[[rules]]
description = "GitLab Runner Registration Token"
id = "gitlab-rrt"
regex = '''GR1348941[0-9a-zA-Z\-\_]{20}'''
keywords = [
"gr1348941",
]

[[rules]]
description = "Gitter Access Token"
id = "gitter-access-token"
Expand Down

0 comments on commit afdccad

Please sign in to comment.