cloudflare.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. var global_keys = []string{
  8. `cloudflare_global_api_key = "d3d1443e0adc9c24564c6c5676d679d47e2ca"`, // gitleaks:allow
  9. `CLOUDFLARE_GLOBAL_API_KEY: 674538c7ecac77d064958a04a83d9e9db068c`, // gitleaks:allow
  10. `cloudflare: "0574b9f43978174cc2cb9a1068681225433c4"`, // gitleaks:allow
  11. }
  12. var api_keys = []string{
  13. `cloudflare_api_key = "Bu0rrK-lerk6y0Suqo1qSqlDDajOk61wZchCkje4"`, // gitleaks:allow
  14. `CLOUDFLARE_API_KEY: 5oK0U90ME14yU6CVxV90crvfqVlNH2wRKBwcLWDc`, // gitleaks:allow
  15. `cloudflare: "oj9Yoyq0zmOyWmPPob1aoY5YSNNuJ0fbZSOURBlX"`, // gitleaks:allow
  16. }
  17. var origin_ca_keys = []string{
  18. `CLOUDFLARE_ORIGIN_CA: v1.0-aaa334dc886f30631ba0a610-0d98ef66290d7e50aac7c27b5986c99e6f3f1084c881d8ac0eae5de1d1aa0644076ff57022069b3237d19afe60ad045f207ef2b16387ee37b749441b2ae2e9ebe5b4606e846475d4a5`,
  19. `CLOUDFLARE_ORIGIN_CA: v1.0-15d20c7fccb4234ac5cdd756-d5c2630d1b606535cf9320ae7456b090e0896cec64169a92fae4e931ab0f72f111b2e4ffed5b2bb40f6fba6b2214df23b188a23693d59ce3fb0d28f7e89a2206d98271b002dac695ed`,
  20. }
  21. var identifiers = []string{"cloudflare"}
  22. func CloudflareGlobalAPIKey() *config.Rule {
  23. // define rule
  24. r := config.Rule{
  25. RuleID: "cloudflare-global-api-key",
  26. Description: "Detected a Cloudflare Global API Key, potentially compromising cloud application deployments and operational security.",
  27. Regex: utils.GenerateSemiGenericRegex(identifiers, utils.Hex("37"), true),
  28. Entropy: 2,
  29. Keywords: identifiers,
  30. }
  31. // validate
  32. tps := utils.GenerateSampleSecrets("cloudflare", secrets.NewSecret(utils.Hex("37")))
  33. tps = append(tps, global_keys...)
  34. fps := append(api_keys, origin_ca_keys...)
  35. return utils.Validate(r, tps, fps)
  36. }
  37. func CloudflareAPIKey() *config.Rule {
  38. // define rule
  39. r := config.Rule{
  40. RuleID: "cloudflare-api-key",
  41. Description: "Detected a Cloudflare API Key, potentially compromising cloud application deployments and operational security.",
  42. Regex: utils.GenerateSemiGenericRegex(identifiers, utils.AlphaNumericExtendedShort("40"), true),
  43. Entropy: 2,
  44. Keywords: identifiers,
  45. }
  46. // validate
  47. tps := utils.GenerateSampleSecrets("cloudflare", secrets.NewSecret(utils.AlphaNumericExtendedShort("40")))
  48. tps = append(tps, api_keys...)
  49. fps := append(global_keys, origin_ca_keys...)
  50. return utils.Validate(r, tps, fps)
  51. }
  52. func CloudflareOriginCAKey() *config.Rule {
  53. ca_identifiers := append(identifiers, "v1.0-")
  54. // define rule
  55. r := config.Rule{
  56. Description: "Detected a Cloudflare Origin CA Key, potentially compromising cloud application deployments and operational security.",
  57. RuleID: "cloudflare-origin-ca-key",
  58. Regex: utils.GenerateUniqueTokenRegex(`v1\.0-`+utils.Hex("24")+"-"+utils.Hex("146"), false),
  59. Entropy: 2,
  60. Keywords: ca_identifiers,
  61. }
  62. // validate
  63. tps := utils.GenerateSampleSecrets("cloudflare", "v1.0-aaa334dc886f30631ba0a610-0d98ef66290d7e50aac7c27b5986c99e6f3f1084c881d8ac0eae5de1d1aa0644076ff57022069b3237d19afe60ad045f207ef2b16387ee37b749441b2ae2e9ebe5b4606e846475d4a5")
  64. tps = append(tps, origin_ca_keys...)
  65. fps := append(global_keys, api_keys...)
  66. return utils.Validate(r, tps, fps)
  67. }