stripe.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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 := []string{
  25. "stripeToken := \"sk_test_" + secrets.NewSecret(utils.AlphaNumeric("30")) + "\"",
  26. "sk_test_51OuEMLAlTWGaDypq4P5cuDHbuKeG4tAGPYHJpEXQ7zE8mKK3jkhTFPvCxnSSK5zB5EQZrJsYdsatNmAHGgb0vSKD00GTMSWRHs", // gitleaks:allow
  27. "rk_prod_51OuEMLAlTWGaDypquDn9aZigaJOsa9NR1w1BxZXs9JlYsVVkv5XDu6aLmAxwt5Tgun5WcSwQMKzQyqV16c9iD4sx00BRijuoon", // gitleaks:allow
  28. }
  29. fps := []string{"nonMatchingToken := \"task_test_" + secrets.NewSecret(utils.AlphaNumeric("30")) + "\""}
  30. return utils.Validate(r, tps, fps)
  31. }