easypost.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "regexp"
  5. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  6. "github.com/zricethezav/gitleaks/v8/config"
  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}`),
  14. Entropy: 2,
  15. Keywords: []string{"EZAK"},
  16. }
  17. // validate
  18. tps := []string{
  19. utils.GenerateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(utils.AlphaNumeric("54"))),
  20. }
  21. return utils.Validate(r, tps, nil)
  22. }
  23. func EasyPostTestAPI() *config.Rule {
  24. // define rule
  25. r := config.Rule{
  26. RuleID: "easypost-test-api-token",
  27. Description: "Detected an EasyPost test API token, risking exposure of test environments and potentially sensitive shipment data.",
  28. Regex: regexp.MustCompile(`\bEZTK(?i)[a-z0-9]{54}`),
  29. Entropy: 2,
  30. Keywords: []string{"EZTK"},
  31. }
  32. // validate
  33. tps := []string{
  34. utils.GenerateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(utils.AlphaNumeric("54"))),
  35. }
  36. return utils.Validate(r, tps, nil)
  37. }