easypost.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package rules
  2. import (
  3. regexp "github.com/wasilibs/go-re2"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  7. )
  8. func EasyPost() *config.Rule {
  9. // define rule
  10. r := config.Rule{
  11. RuleID: "easypost-api-token",
  12. Description: "Identified an EasyPost API token, which could lead to unauthorized postal and shipment service access and data exposure.",
  13. Regex: regexp.MustCompile(`\bEZAK(?i)[a-z0-9]{54}\b`),
  14. Entropy: 2,
  15. Keywords: []string{"EZAK"},
  16. }
  17. // validate
  18. tps := utils.GenerateSampleSecrets("EZAK", "EZAK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`))
  19. tps = append(tps,
  20. "EZAK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`),
  21. "example.com?t=EZAK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`)+"&q=1",
  22. )
  23. fps := []string{
  24. // random base64 encoded string
  25. `...6wqX6fNUXA/rYqRvfQ+EZAKGqQRiRyqAFRQshGPWOIAwNWGORfKHSBnVNFtVmWYoW6PH23lkqbbDWep95C/3VmWq/edti6...`, // gitleaks:allow
  26. }
  27. return utils.Validate(r, tps, fps)
  28. }
  29. func EasyPostTestAPI() *config.Rule {
  30. // define rule
  31. r := config.Rule{
  32. RuleID: "easypost-test-api-token",
  33. Description: "Detected an EasyPost test API token, risking exposure of test environments and potentially sensitive shipment data.",
  34. Regex: regexp.MustCompile(`\bEZTK(?i)[a-z0-9]{54}\b`),
  35. Entropy: 2,
  36. Keywords: []string{"EZTK"},
  37. }
  38. // validate
  39. tps := utils.GenerateSampleSecrets("EZTK", secrets.NewSecret(`EZTK[a-zA-Z0-9]{54}`))
  40. tps = append(tps, secrets.NewSecret(`EZTK[a-zA-Z0-9]{54}`))
  41. tps = append(tps,
  42. "EZTK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`),
  43. "example.com?t=EZTK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`)+"&q=1",
  44. )
  45. fps := []string{
  46. // random base64 encoded string
  47. `...6wqX6fNUXA/rYqRvfQ+EZTKGqQRiRyqAFRQshGPWOIAwNWGORfKHSBnVNFtVmWYoW6PH23lkqbbDWep95C/3VmWq/edti6...`, // gitleaks:allow
  48. }
  49. return utils.Validate(r, tps, fps)
  50. }