sidekiq.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package rules
  2. import (
  3. "regexp"
  4. "github.com/zricethezav/gitleaks/v8/config"
  5. )
  6. func SidekiqSecret() *config.Rule {
  7. // define rule
  8. r := config.Rule{
  9. Description: "Discovered a Sidekiq Secret, which could lead to compromised background job processing and application data breaches.",
  10. RuleID: "sidekiq-secret",
  11. Regex: generateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
  12. `[a-f0-9]{8}:[a-f0-9]{8}`, true),
  13. Keywords: []string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
  14. }
  15. // validate
  16. tps := []string{
  17. "BUNDLE_ENTERPRISE__CONTRIBSYS__COM: cafebabe:deadbeef",
  18. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef",
  19. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM = cafebabe:deadbeef",
  20. "BUNDLE_GEMS__CONTRIBSYS__COM: \"cafebabe:deadbeef\"",
  21. "export BUNDLE_GEMS__CONTRIBSYS__COM=\"cafebabe:deadbeef\"",
  22. "export BUNDLE_GEMS__CONTRIBSYS__COM = \"cafebabe:deadbeef\"",
  23. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;",
  24. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef && echo 'hello world'",
  25. }
  26. return validate(r, tps, nil)
  27. }
  28. func SidekiqSensitiveUrl() *config.Rule {
  29. // define rule
  30. r := config.Rule{
  31. Description: "Uncovered a Sidekiq Sensitive URL, potentially exposing internal job queues and sensitive operation details.",
  32. RuleID: "sidekiq-sensitive-url",
  33. SecretGroup: 2,
  34. Regex: regexp.MustCompile(`(?i)\b(http(?:s??):\/\/)([a-f0-9]{8}:[a-f0-9]{8})@(?:gems.contribsys.com|enterprise.contribsys.com)(?:[\/|\#|\?|:]|$)`),
  35. Keywords: []string{"gems.contribsys.com", "enterprise.contribsys.com"},
  36. }
  37. // validate
  38. tps := []string{
  39. "https://cafebabe:deadbeef@gems.contribsys.com/",
  40. "https://cafebabe:deadbeef@gems.contribsys.com",
  41. "https://cafeb4b3:d3adb33f@enterprise.contribsys.com/",
  42. "https://cafeb4b3:d3adb33f@enterprise.contribsys.com",
  43. "http://cafebabe:deadbeef@gems.contribsys.com/",
  44. "http://cafebabe:deadbeef@gems.contribsys.com",
  45. "http://cafeb4b3:d3adb33f@enterprise.contribsys.com/",
  46. "http://cafeb4b3:d3adb33f@enterprise.contribsys.com",
  47. "http://cafeb4b3:d3adb33f@enterprise.contribsys.com#heading1",
  48. "http://cafeb4b3:d3adb33f@enterprise.contribsys.com?param1=true&param2=false",
  49. "http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80",
  50. "http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80/path?param1=true&param2=false#heading1",
  51. }
  52. return validate(r, tps, nil)
  53. }