mailgun.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  4. "github.com/zricethezav/gitleaks/v8/config"
  5. )
  6. func MailGunPrivateAPIToken() *config.Rule {
  7. // define rule
  8. r := config.Rule{
  9. RuleID: "mailgun-private-api-token",
  10. Description: "Found a Mailgun private API token, risking unauthorized email service operations and data breaches.",
  11. Regex: generateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`, true),
  12. Keywords: []string{
  13. "mailgun",
  14. },
  15. }
  16. // validate
  17. tps := []string{
  18. generateSampleSecret("mailgun", "key-"+secrets.NewSecret(hex("32"))),
  19. }
  20. return validate(r, tps, nil)
  21. }
  22. func MailGunPubAPIToken() *config.Rule {
  23. // define rule
  24. r := config.Rule{
  25. RuleID: "mailgun-pub-key",
  26. Description: "Discovered a Mailgun public validation key, which could expose email verification processes and associated data.",
  27. Regex: generateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`, true),
  28. Keywords: []string{
  29. "mailgun",
  30. },
  31. }
  32. // validate
  33. tps := []string{
  34. generateSampleSecret("mailgun", "pubkey-"+secrets.NewSecret(hex("32"))),
  35. }
  36. return validate(r, tps, nil)
  37. }
  38. func MailGunSigningKey() *config.Rule {
  39. // define rule
  40. r := config.Rule{
  41. RuleID: "mailgun-signing-key",
  42. Description: "Uncovered a Mailgun webhook signing key, potentially compromising email automation and data integrity.",
  43. Regex: generateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`, true),
  44. Keywords: []string{
  45. "mailgun",
  46. },
  47. }
  48. // validate
  49. tps := []string{
  50. generateSampleSecret("mailgun", secrets.NewSecret(hex("32"))+"-00001111-22223333"),
  51. }
  52. return validate(r, tps, nil)
  53. }