newrelic.go 2.5 KB

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