cloudflare.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/config"
  4. )
  5. var global_keys = []string{
  6. `cloudflare_global_api_key = "d3d1443e0adc9c24564c6c5676d679d47e2ca"`, // gitleaks:allow
  7. `CLOUDFLARE_GLOBAL_API_KEY: 674538c7ecac77d064958a04a83d9e9db068c`, // gitleaks:allow
  8. `cloudflare: "0574b9f43978174cc2cb9a1068681225433c4"`, // gitleaks:allow
  9. }
  10. var api_keys = []string{
  11. `cloudflare_api_key = "Bu0rrK-lerk6y0Suqo1qSqlDDajOk61wZchCkje4"`, // gitleaks:allow
  12. `CLOUDFLARE_API_KEY: 5oK0U90ME14yU6CVxV90crvfqVlNH2wRKBwcLWDc`, // gitleaks:allow
  13. `cloudflare: "oj9Yoyq0zmOyWmPPob1aoY5YSNNuJ0fbZSOURBlX"`, // gitleaks:allow
  14. }
  15. var origin_ca_keys = []string{
  16. `CLOUDFLARE_ORIGIN_CA: v1.0-aaa334dc886f30631ba0a610-0d98ef66290d7e50aac7c27b5986c99e6f3f1084c881d8ac0eae5de1d1aa0644076ff57022069b3237d19afe60ad045f207ef2b16387ee37b749441b2ae2e9ebe5b4606e846475d4a5`,
  17. `CLOUDFLARE_ORIGIN_CA: v1.0-15d20c7fccb4234ac5cdd756-d5c2630d1b606535cf9320ae7456b090e0896cec64169a92fae4e931ab0f72f111b2e4ffed5b2bb40f6fba6b2214df23b188a23693d59ce3fb0d28f7e89a2206d98271b002dac695ed`,
  18. }
  19. var identifiers = []string{"cloudflare"}
  20. func CloudflareGlobalAPIKey() *config.Rule {
  21. // define rule
  22. r := config.Rule{
  23. Description: "Detected a Cloudflare Global API Key, potentially compromising cloud application deployments and operational security.",
  24. RuleID: "cloudflare-global-api-key",
  25. Regex: generateSemiGenericRegex(identifiers, hex("37"), true),
  26. Keywords: identifiers,
  27. }
  28. // validate
  29. tps := global_keys
  30. fps := append(api_keys, origin_ca_keys...)
  31. return validate(r, tps, fps)
  32. }
  33. func CloudflareAPIKey() *config.Rule {
  34. // define rule
  35. r := config.Rule{
  36. Description: "Detected a Cloudflare API Key, potentially compromising cloud application deployments and operational security.",
  37. RuleID: "cloudflare-api-key",
  38. Regex: generateSemiGenericRegex(identifiers, alphaNumericExtendedShort("40"), true),
  39. Keywords: identifiers,
  40. }
  41. // validate
  42. tps := api_keys
  43. fps := append(global_keys, origin_ca_keys...)
  44. return validate(r, tps, fps)
  45. }
  46. func CloudflareOriginCAKey() *config.Rule {
  47. ca_identifiers := append(identifiers, "v1.0-")
  48. // define rule
  49. r := config.Rule{
  50. Description: "Detected a Cloudflare Origin CA Key, potentially compromising cloud application deployments and operational security.",
  51. RuleID: "cloudflare-origin-ca-key",
  52. Regex: generateUniqueTokenRegex(`v1\.0-`+hex("24")+"-"+hex("146"), false),
  53. Keywords: ca_identifiers,
  54. }
  55. // validate
  56. tps := origin_ca_keys
  57. fps := append(global_keys, api_keys...)
  58. return validate(r, tps, fps)
  59. }