cloudflare.go 2.7 KB

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