gitlab.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package rules
  2. import (
  3. "regexp"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func GitlabPat() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "Identified a GitLab Personal Access Token, risking unauthorized access to GitLab repositories and codebase exposure.",
  11. RuleID: "gitlab-pat",
  12. Regex: regexp.MustCompile(`glpat-[0-9a-zA-Z\-\_]{20}`),
  13. Keywords: []string{"glpat-"},
  14. }
  15. // validate
  16. tps := []string{
  17. generateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(alphaNumeric("20"))),
  18. }
  19. return validate(r, tps, nil)
  20. }
  21. func GitlabPipelineTriggerToken() *config.Rule {
  22. // define rule
  23. r := config.Rule{
  24. Description: "Found a GitLab Pipeline Trigger Token, potentially compromising continuous integration workflows and project security.",
  25. RuleID: "gitlab-ptt",
  26. Regex: regexp.MustCompile(`glptt-[0-9a-f]{40}`),
  27. Keywords: []string{"glptt-"},
  28. }
  29. // validate
  30. tps := []string{
  31. generateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(hex("40"))),
  32. }
  33. return validate(r, tps, nil)
  34. }
  35. func GitlabRunnerRegistrationToken() *config.Rule {
  36. // define rule
  37. r := config.Rule{
  38. Description: "Discovered a GitLab Runner Registration Token, posing a risk to CI/CD pipeline integrity and unauthorized access.",
  39. RuleID: "gitlab-rrt",
  40. Regex: regexp.MustCompile(`GR1348941[0-9a-zA-Z\-\_]{20}`),
  41. Keywords: []string{"GR1348941"},
  42. }
  43. // validate
  44. tps := []string{
  45. generateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(alphaNumeric("20"))),
  46. }
  47. return validate(r, tps, nil)
  48. }