heroku.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func Heroku() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "Detected a Heroku API Key, potentially compromising cloud application deployments and operational security.",
  11. RuleID: "heroku-api-key",
  12. Regex: utils.GenerateSemiGenericRegex([]string{"heroku"}, utils.Hex8_4_4_4_12(), true),
  13. Keywords: []string{"heroku"},
  14. }
  15. // validate
  16. tps := utils.GenerateSampleSecrets("heroku", secrets.NewSecret(utils.Hex8_4_4_4_12()))
  17. tps = append(tps,
  18. `const HEROKU_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
  19. `heroku_api_key = "832d2129-a846-4e27-99f4-7004b6ad53ef"`, // gitleaks:allow
  20. )
  21. return utils.Validate(r, tps, nil)
  22. }
  23. func HerokuV2() *config.Rule {
  24. // define rule
  25. r := config.Rule{
  26. Description: "Detected a Heroku API Key, potentially compromising cloud application deployments and operational security.",
  27. RuleID: "heroku-api-key-v2",
  28. Regex: utils.GenerateUniqueTokenRegex(`(HRKU-AA[0-9a-zA-Z_-]{58})`, false),
  29. Entropy: 4,
  30. Keywords: []string{"HRKU-AA"},
  31. }
  32. // validate
  33. tps := utils.GenerateSampleSecrets("heroku", secrets.NewSecret(`\b(HRKU-AA[0-9a-zA-Z_-]{58})\b`))
  34. tps = append(tps,
  35. `const KEY = "HRKU-AAlQ1aVoHDujJ9QsDHdHlHO0hbzhoERRSO45ZQusSYHg_____w4_hLrAym_u""`,
  36. `API_Key = "HRKU-AAy9Ppr_HD2pPuTyIiTYInO0hbzhoERRSO93ZQusSYHgaD7_WQ07FnF7L9FX"`,
  37. )
  38. return utils.Validate(r, tps, nil)
  39. }