planetscale.go 2.6 KB

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