stripe.go 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  4. "github.com/zricethezav/gitleaks/v8/config"
  5. )
  6. func StripeAccessToken() *config.Rule {
  7. // define rule
  8. r := config.Rule{
  9. Description: "Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data.",
  10. RuleID: "stripe-access-token",
  11. Regex: generateUniqueTokenRegex(`(sk|rk)_(test|live|prod)_[0-9a-z]{10,99}`, true),
  12. Keywords: []string{
  13. "sk_test",
  14. "sk_live",
  15. "sk_prod",
  16. "rk_test",
  17. "rk_live",
  18. "rk_prod",
  19. },
  20. }
  21. // validate
  22. tps := []string{
  23. "stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\"",
  24. "sk_test_51OuEMLAlTWGaDypq4P5cuDHbuKeG4tAGPYHJpEXQ7zE8mKK3jkhTFPvCxnSSK5zB5EQZrJsYdsatNmAHGgb0vSKD00GTMSWRHs", // gitleaks:allow
  25. "rk_prod_51OuEMLAlTWGaDypquDn9aZigaJOsa9NR1w1BxZXs9JlYsVVkv5XDu6aLmAxwt5Tgun5WcSwQMKzQyqV16c9iD4sx00BRijuoon", // gitleaks:allow
  26. }
  27. fps := []string{"nonMatchingToken := \"task_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
  28. return validate(r, tps, fps)
  29. }