shopify.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package rules
  2. import (
  3. "regexp"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func ShopifySharedSecret() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "Shopify shared secret",
  11. RuleID: "shopify-shared-secret",
  12. Regex: regexp.MustCompile(`shpss_[a-fA-F0-9]{32}`),
  13. Keywords: []string{"shpss_"},
  14. }
  15. // validate
  16. tps := []string{"shopifySecret := \"shpss_" + secrets.NewSecret(hex("32")) + "\""}
  17. return validate(r, tps, nil)
  18. }
  19. func ShopifyAccessToken() *config.Rule {
  20. // define rule
  21. r := config.Rule{
  22. Description: "Shopify access token",
  23. RuleID: "shopify-access-token",
  24. Regex: regexp.MustCompile(`shpat_[a-fA-F0-9]{32}`),
  25. Keywords: []string{"shpat_"},
  26. }
  27. // validate
  28. tps := []string{"shopifyToken := \"shpat_" + secrets.NewSecret(hex("32")) + "\""}
  29. return validate(r, tps, nil)
  30. }
  31. func ShopifyCustomAccessToken() *config.Rule {
  32. // define rule
  33. r := config.Rule{
  34. Description: "Shopify custom access token",
  35. RuleID: "shopify-custom-access-token",
  36. Regex: regexp.MustCompile(`shpca_[a-fA-F0-9]{32}`),
  37. Keywords: []string{"shpca_"},
  38. }
  39. // validate
  40. tps := []string{"shopifyToken := \"shpca_" + secrets.NewSecret(hex("32")) + "\""}
  41. return validate(r, tps, nil)
  42. }
  43. func ShopifyPrivateAppAccessToken() *config.Rule {
  44. // define rule
  45. r := config.Rule{
  46. Description: "Shopify private app access token",
  47. RuleID: "shopify-private-app-access-token",
  48. Regex: regexp.MustCompile(`shppa_[a-fA-F0-9]{32}`),
  49. Keywords: []string{"shppa_"},
  50. }
  51. // validate
  52. tps := []string{"shopifyToken := \"shppa_" + secrets.NewSecret(hex("32")) + "\""}
  53. return validate(r, tps, nil)
  54. }