newrelic.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. )
  7. func NewRelicUserID() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. RuleID: "new-relic-user-api-key",
  11. Description: "Discovered a New Relic user API Key, which could lead to compromised application insights and performance monitoring.",
  12. Regex: utils.GenerateSemiGenericRegex([]string{
  13. "new-relic",
  14. "newrelic",
  15. "new_relic",
  16. }, `NRAK-[a-z0-9]{27}`, true),
  17. Keywords: []string{
  18. "NRAK",
  19. },
  20. }
  21. // validate
  22. tps := utils.GenerateSampleSecrets("new-relic", "NRAK-"+secrets.NewSecret(utils.AlphaNumeric("27")))
  23. return utils.Validate(r, tps, nil)
  24. }
  25. func NewRelicUserKey() *config.Rule {
  26. // define rule
  27. r := config.Rule{
  28. RuleID: "new-relic-user-api-id",
  29. Description: "Found a New Relic user API ID, posing a risk to application monitoring services and data integrity.",
  30. Regex: utils.GenerateSemiGenericRegex([]string{
  31. "new-relic",
  32. "newrelic",
  33. "new_relic",
  34. }, utils.AlphaNumeric("64"), true),
  35. Keywords: []string{
  36. "new-relic",
  37. "newrelic",
  38. "new_relic",
  39. },
  40. }
  41. // validate
  42. tps := utils.GenerateSampleSecrets("new-relic", secrets.NewSecret(utils.AlphaNumeric("64")))
  43. return utils.Validate(r, tps, nil)
  44. }
  45. func NewRelicBrowserAPIKey() *config.Rule {
  46. // define rule
  47. r := config.Rule{
  48. RuleID: "new-relic-browser-api-token",
  49. Description: "Identified a New Relic ingest browser API token, risking unauthorized access to application performance data and analytics.",
  50. Regex: utils.GenerateSemiGenericRegex([]string{
  51. "new-relic",
  52. "newrelic",
  53. "new_relic",
  54. }, `NRJS-[a-f0-9]{19}`, true),
  55. Keywords: []string{
  56. "NRJS-",
  57. },
  58. }
  59. // validate
  60. tps := utils.GenerateSampleSecrets("new-relic", "NRJS-"+secrets.NewSecret(utils.Hex("19")))
  61. return utils.Validate(r, tps, nil)
  62. }
  63. func NewRelicInsertKey() *config.Rule {
  64. // define rule
  65. r := config.Rule{
  66. RuleID: "new-relic-insert-key",
  67. Description: "Discovered a New Relic insight insert key, compromising data injection into the platform.",
  68. Regex: utils.GenerateSemiGenericRegex([]string{
  69. "new-relic",
  70. "newrelic",
  71. "new_relic",
  72. }, `NRII-[a-z0-9-]{32}`, true),
  73. Keywords: []string{
  74. "NRII-",
  75. },
  76. }
  77. // validate
  78. tps := utils.GenerateSampleSecrets("new-relic", "NRII-"+secrets.NewSecret(utils.Hex("32")))
  79. return utils.Validate(r, tps, nil)
  80. }