newrelic.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  4. "github.com/zricethezav/gitleaks/v8/config"
  5. )
  6. func NewRelicUserID() *config.Rule {
  7. // define rule
  8. r := config.Rule{
  9. RuleID: "new-relic-user-api-key",
  10. Description: "Discovered a New Relic user API Key, which could lead to compromised application insights and performance monitoring.",
  11. Regex: generateSemiGenericRegex([]string{
  12. "new-relic",
  13. "newrelic",
  14. "new_relic",
  15. }, `NRAK-[a-z0-9]{27}`, true),
  16. Keywords: []string{
  17. "NRAK",
  18. },
  19. }
  20. // validate
  21. tps := []string{
  22. generateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(alphaNumeric("27"))),
  23. }
  24. return validate(r, tps, nil)
  25. }
  26. func NewRelicUserKey() *config.Rule {
  27. // define rule
  28. r := config.Rule{
  29. RuleID: "new-relic-user-api-id",
  30. Description: "Found a New Relic user API ID, posing a risk to application monitoring services and data integrity.",
  31. Regex: generateSemiGenericRegex([]string{
  32. "new-relic",
  33. "newrelic",
  34. "new_relic",
  35. }, alphaNumeric("64"), true),
  36. Keywords: []string{
  37. "new-relic",
  38. "newrelic",
  39. "new_relic",
  40. },
  41. }
  42. // validate
  43. tps := []string{
  44. generateSampleSecret("new-relic", secrets.NewSecret(alphaNumeric("64"))),
  45. }
  46. return validate(r, tps, nil)
  47. }
  48. func NewRelicBrowserAPIKey() *config.Rule {
  49. // define rule
  50. r := config.Rule{
  51. RuleID: "new-relic-browser-api-token",
  52. Description: "Identified a New Relic ingest browser API token, risking unauthorized access to application performance data and analytics.",
  53. Regex: generateSemiGenericRegex([]string{
  54. "new-relic",
  55. "newrelic",
  56. "new_relic",
  57. }, `NRJS-[a-f0-9]{19}`, true),
  58. Keywords: []string{
  59. "NRJS-",
  60. },
  61. }
  62. // validate
  63. tps := []string{
  64. generateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(hex("19"))),
  65. }
  66. return validate(r, tps, nil)
  67. }