sidekiq.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
  4. "regexp"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. func SidekiqSecret() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "Discovered a Sidekiq Secret, which could lead to compromised background job processing and application data breaches.",
  11. RuleID: "sidekiq-secret",
  12. Regex: utils.GenerateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
  13. `[a-f0-9]{8}:[a-f0-9]{8}`, true),
  14. Keywords: []string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
  15. }
  16. // validate
  17. tps := []string{
  18. "BUNDLE_ENTERPRISE__CONTRIBSYS__COM: cafebabe:deadbeef",
  19. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef",
  20. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM = cafebabe:deadbeef",
  21. "BUNDLE_GEMS__CONTRIBSYS__COM: \"cafebabe:deadbeef\"",
  22. "export BUNDLE_GEMS__CONTRIBSYS__COM=\"cafebabe:deadbeef\"",
  23. "export BUNDLE_GEMS__CONTRIBSYS__COM = \"cafebabe:deadbeef\"",
  24. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;",
  25. "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef && echo 'hello world'",
  26. }
  27. return utils.Validate(r, tps, nil)
  28. }
  29. func SidekiqSensitiveUrl() *config.Rule {
  30. // define rule
  31. r := config.Rule{
  32. Description: "Uncovered a Sidekiq Sensitive URL, potentially exposing internal job queues and sensitive operation details.",
  33. RuleID: "sidekiq-sensitive-url",
  34. Regex: regexp.MustCompile(`(?i)\bhttps?://([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 utils.Validate(r, tps, nil)
  53. }