planetscale.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func PlanetScalePassword() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. RuleID: "planetscale-password",
  11. Description: "Discovered a PlanetScale password, which could lead to unauthorized database operations and data breaches.",
  12. Regex: utils.GenerateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`, true),
  13. Keywords: []string{
  14. "pscale_pw_",
  15. },
  16. }
  17. // validate
  18. tps := []string{
  19. utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
  20. utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
  21. utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
  22. }
  23. return utils.Validate(r, tps, nil)
  24. }
  25. func PlanetScaleAPIToken() *config.Rule {
  26. // define rule
  27. r := config.Rule{
  28. RuleID: "planetscale-api-token",
  29. Description: "Identified a PlanetScale API token, potentially compromising database management and operations.",
  30. Regex: utils.GenerateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`, true),
  31. Keywords: []string{
  32. "pscale_tkn_",
  33. },
  34. }
  35. // validate
  36. tps := []string{
  37. utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
  38. utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
  39. utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
  40. }
  41. return utils.Validate(r, tps, nil)
  42. }
  43. func PlanetScaleOAuthToken() *config.Rule {
  44. // define rule
  45. r := config.Rule{
  46. RuleID: "planetscale-oauth-token",
  47. Description: "Found a PlanetScale OAuth token, posing a risk to database access control and sensitive data integrity.",
  48. Regex: utils.GenerateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`, true),
  49. Keywords: []string{
  50. "pscale_oauth_",
  51. },
  52. }
  53. // validate
  54. tps := []string{
  55. utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
  56. utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
  57. utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
  58. }
  59. return utils.Validate(r, tps, nil)
  60. }