mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
Generate comprehensive secret samples (#1484)
* feat(config): comprehensive samples * refactor(config): use new generate func * chore(config): comment unsupported cases * feat(config): enable '?=' case * feat(config): enable '+=' case * feat(config): enable escaped json case * feat(config): enable '<' (xml) case * feat(config): enable multiline yaml case * chore(config): add comment case * feat(config): add php cases * feat(config): add java case * chore(config): address review comments * fix(config): prevent matching '==' * feat(config): add URL cases * chore(config): revert regex changes To be tackled in separate PRs.
This commit is contained in:
1 parent
d1d9054ef0
commit
c11adc91ad
110 files changed
+436
-621
No files matched your search
@@ -14,15 +14,13 @@ import (
|
||||
|
||||
func GitlabCiCdJobToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitLab CI/CD Job Token, potential access to projects and some APIs on behalf of a user while the CI job is running.",
|
||||
RuleID: "gitlab-cicd-job-token",
|
||||
Description: "Identified a GitLab CI/CD Job Token, potential access to projects and some APIs on behalf of a user while the CI job is running.",
|
||||
Regex: regexp.MustCompile(`glcbt-[0-9a-zA-Z]{1,5}_[0-9a-zA-Z_-]{20}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glcbt-"},
|
||||
}
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glcbt-"+secrets.NewSecret(utils.AlphaNumeric("5"))+"_"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glcbt-"+secrets.NewSecret(utils.AlphaNumeric("5"))+"_"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
@@ -42,71 +40,61 @@ func GitlabDeployToken() *config.Rule {
|
||||
|
||||
func GitlabFeatureFlagClientToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitLab feature flag client token, risks exposing user lists and features flags used by an application.",
|
||||
RuleID: "gitlab-feature-flag-client-token",
|
||||
Description: "Identified a GitLab feature flag client token, risks exposing user lists and features flags used by an application.",
|
||||
Regex: regexp.MustCompile(`glffct-[0-9a-zA-Z_\-]{20}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glffct-"},
|
||||
}
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glffct-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glffct-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabFeedToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitLab feed token, risking exposure of user data.",
|
||||
RuleID: "gitlab-feed-token",
|
||||
Description: "Identified a GitLab feed token, risking exposure of user data.",
|
||||
Regex: regexp.MustCompile(`glft-[0-9a-zA-Z_\-]{20}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glft-"},
|
||||
}
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glft-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glft-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabIncomingMailToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitLab incoming mail token, risking manipulation of data sent by mail.",
|
||||
RuleID: "gitlab-incoming-mail-token",
|
||||
Description: "Identified a GitLab incoming mail token, risking manipulation of data sent by mail.",
|
||||
Regex: regexp.MustCompile(`glimt-[0-9a-zA-Z_\-]{25}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glimt-"},
|
||||
}
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glimt-"+secrets.NewSecret(utils.AlphaNumeric("25"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glimt-"+secrets.NewSecret(utils.AlphaNumeric("25")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabKubernetesAgentToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitLab Kubernetes Agent token, risking access to repos and registry of projects connected via agent.",
|
||||
RuleID: "gitlab-kubernetes-agent-token",
|
||||
Description: "Identified a GitLab Kubernetes Agent token, risking access to repos and registry of projects connected via agent.",
|
||||
Regex: regexp.MustCompile(`glagent-[0-9a-zA-Z_\-]{50}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glagent-"},
|
||||
}
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glagent-"+secrets.NewSecret(utils.AlphaNumeric("50"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glagent-"+secrets.NewSecret(utils.AlphaNumeric("50")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabOauthAppSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitLab OIDC Application Secret, risking access to apps using GitLab as authentication provider.",
|
||||
RuleID: "gitlab-oauth-app-secret",
|
||||
Description: "Identified a GitLab OIDC Application Secret, risking access to apps using GitLab as authentication provider.",
|
||||
Regex: regexp.MustCompile(`gloas-[0-9a-zA-Z_\-]{64}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"gloas-"},
|
||||
}
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "gloas-"+secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "gloas-"+secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
@@ -119,9 +107,8 @@ func GitlabPat() *config.Rule {
|
||||
Keywords: []string{"glpat-"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
// validate
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glpat-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
fps := []string{
|
||||
"glpat-XXXXXXXXXXX-XXXXXXXX",
|
||||
}
|
||||
@@ -137,9 +124,8 @@ func GitlabPipelineTriggerToken() *config.Rule {
|
||||
Keywords: []string{"glptt-"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(utils.Hex("40"))),
|
||||
}
|
||||
// validate
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glptt-"+secrets.NewSecret(utils.Hex("40")))
|
||||
fps := []string{
|
||||
"glptt-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
@@ -155,9 +141,7 @@ func GitlabRunnerRegistrationToken() *config.Rule {
|
||||
Keywords: []string{"GR1348941"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "GR1348941"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
fps := []string{
|
||||
"GR134894112312312312312312312",
|
||||
"GR1348941XXXXXXXXXXXXXXXXXXXX",
|
||||
@@ -167,45 +151,40 @@ func GitlabRunnerRegistrationToken() *config.Rule {
|
||||
|
||||
func GitlabRunnerAuthenticationToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a GitLab Runner Authentication Token, posing a risk to CI/CD pipeline integrity and unauthorized access.",
|
||||
RuleID: "gitlab-runner-authentication-token",
|
||||
Description: "Discovered a GitLab Runner Authentication Token, posing a risk to CI/CD pipeline integrity and unauthorized access.",
|
||||
Regex: regexp.MustCompile(`glrt-[0-9a-zA-Z_\-]{20}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glrt-"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glrt-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glrt-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabScimToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a GitLab SCIM Token, posing a risk to unauthorized access for a organization or instance.",
|
||||
RuleID: "gitlab-scim-token",
|
||||
Description: "Discovered a GitLab SCIM Token, posing a risk to unauthorized access for a organization or instance.",
|
||||
Regex: regexp.MustCompile(`glsoat-[0-9a-zA-Z_\-]{20}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"glsoat-"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "glsoat-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "glsoat-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabSessionCookie() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a GitLab Session Cookie, posing a risk to unauthorized access to a user account.",
|
||||
RuleID: "gitlab-session-cookie",
|
||||
Description: "Discovered a GitLab Session Cookie, posing a risk to unauthorized access to a user account.",
|
||||
Regex: regexp.MustCompile(`_gitlab_session=[0-9a-z]{32}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"_gitlab_session="},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("gitlab", "_gitlab_session="+secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
// validate
|
||||
tps := utils.GenerateSampleSecrets("gitlab", "_gitlab_session="+secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
Reference in new issue
Block a user