easypost.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 EasyPost() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "Identified an EasyPost API token, which could lead to unauthorized postal and shipment service access and data exposure.",
  11. RuleID: "easypost-api-token",
  12. Regex: regexp.MustCompile(`\bEZAK(?i)[a-z0-9]{54}`),
  13. Keywords: []string{"EZAK"},
  14. }
  15. // validate
  16. tps := []string{
  17. generateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(alphaNumeric("54"))),
  18. }
  19. return validate(r, tps, nil)
  20. }
  21. func EasyPostTestAPI() *config.Rule {
  22. // define rule
  23. r := config.Rule{
  24. Description: "Detected an EasyPost test API token, risking exposure of test environments and potentially sensitive shipment data.",
  25. RuleID: "easypost-test-api-token",
  26. Regex: regexp.MustCompile(`\bEZTK(?i)[a-z0-9]{54}`),
  27. Keywords: []string{"EZTK"},
  28. }
  29. // validate
  30. tps := []string{
  31. generateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(alphaNumeric("54"))),
  32. }
  33. return validate(r, tps, nil)
  34. }