stripe.go 1.1 KB

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