easypost.go 1.2 KB

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