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)[\w=\.-]{32,64}`, true),
  13. Entropy: 3,
  14. Keywords: []string{
  15. "pscale_pw_",
  16. },
  17. }
  18. // validate
  19. tps := []string{
  20. utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
  21. utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
  22. utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
  23. }
  24. return utils.Validate(r, tps, nil)
  25. }
  26. func PlanetScaleAPIToken() *config.Rule {
  27. // define rule
  28. r := config.Rule{
  29. RuleID: "planetscale-api-token",
  30. Description: "Identified a PlanetScale API token, potentially compromising database management and operations.",
  31. Regex: utils.GenerateUniqueTokenRegex(`pscale_tkn_(?i)[\w=\.-]{32,64}`, false),
  32. Entropy: 3,
  33. Keywords: []string{
  34. "pscale_tkn_",
  35. },
  36. }
  37. // validate
  38. tps := []string{
  39. utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
  40. utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
  41. utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
  42. }
  43. return utils.Validate(r, tps, nil)
  44. }
  45. func PlanetScaleOAuthToken() *config.Rule {
  46. // define rule
  47. r := config.Rule{
  48. RuleID: "planetscale-oauth-token",
  49. Description: "Found a PlanetScale OAuth token, posing a risk to database access control and sensitive data integrity.",
  50. Regex: utils.GenerateUniqueTokenRegex(`pscale_oauth_[\w=\.-]{32,64}`, false),
  51. Entropy: 3,
  52. Keywords: []string{
  53. "pscale_oauth_",
  54. },
  55. }
  56. // validate
  57. tps := []string{
  58. utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
  59. utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
  60. utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
  61. }
  62. return utils.Validate(r, tps, nil)
  63. }