stripe.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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 StripeAccessToken() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. RuleID: "stripe-access-token",
  11. Description: "Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data.",
  12. Regex: utils.GenerateUniqueTokenRegex(`(?:sk|rk)_(?:test|live|prod)_[a-zA-Z0-9]{10,99}`, false),
  13. Entropy: 2,
  14. Keywords: []string{
  15. "sk_test",
  16. "sk_live",
  17. "sk_prod",
  18. "rk_test",
  19. "rk_live",
  20. "rk_prod",
  21. },
  22. }
  23. // validate
  24. tps := utils.GenerateSampleSecrets("stripe", "sk_test_"+secrets.NewSecret(utils.AlphaNumeric("30")))
  25. tps = append(tps, utils.GenerateSampleSecrets("stripe", "sk_prod_"+secrets.NewSecret(utils.AlphaNumeric("99")))...)
  26. tps = append(tps,
  27. "sk_test_51OuEMLAlTWGaDypq4P5cuDHbuKeG4tAGPYHJpEXQ7zE8mKK3jkhTFPvCxnSSK5zB5EQZrJsYdsatNmAHGgb0vSKD00GTMSWRHs", // gitleaks:allow
  28. "rk_prod_51OuEMLAlTWGaDypquDn9aZigaJOsa9NR1w1BxZXs9JlYsVVkv5XDu6aLmAxwt5Tgun5WcSwQMKzQyqV16c9iD4sx00BRijuoon", // gitleaks:allow
  29. )
  30. fps := []string{"nonMatchingToken := \"task_test_" + secrets.NewSecret(utils.AlphaNumeric("30")) + "\""}
  31. return utils.Validate(r, tps, fps)
  32. }