sidekiq.go 2.8 KB

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