grafana.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 GrafanaApiKey() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. Description: "Identified a Grafana API key, which could compromise monitoring dashboards and sensitive data analytics.",
  11. RuleID: "grafana-api-key",
  12. Regex: utils.GenerateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true),
  13. Keywords: []string{"eyJrIjoi"},
  14. }
  15. // validate
  16. tps := []string{
  17. utils.GenerateSampleSecret("grafana-api-key",
  18. "eyJrIjoi"+
  19. secrets.NewSecret(utils.AlphaNumeric("70"))),
  20. }
  21. return utils.Validate(r, tps, nil)
  22. }
  23. func GrafanaCloudApiToken() *config.Rule {
  24. // define rule
  25. r := config.Rule{
  26. Description: "Found a Grafana cloud API token, risking unauthorized access to cloud-based monitoring services and data exposure.",
  27. RuleID: "grafana-cloud-api-token",
  28. Regex: utils.GenerateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true),
  29. Keywords: []string{"glc_"},
  30. }
  31. // validate
  32. tps := []string{
  33. utils.GenerateSampleSecret("grafana-cloud-api-token",
  34. "glc_"+
  35. secrets.NewSecret(utils.AlphaNumeric("32"))),
  36. }
  37. return utils.Validate(r, tps, nil)
  38. }
  39. func GrafanaServiceAccountToken() *config.Rule {
  40. // define rule
  41. r := config.Rule{
  42. Description: "Discovered a Grafana service account token, posing a risk of compromised monitoring services and data integrity.",
  43. RuleID: "grafana-service-account-token",
  44. Regex: utils.GenerateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true),
  45. Keywords: []string{"glsa_"},
  46. }
  47. // validate
  48. tps := []string{
  49. utils.GenerateSampleSecret("grafana-service-account-token",
  50. "glsa_"+
  51. secrets.NewSecret(utils.AlphaNumeric("32"))+
  52. "_"+
  53. secrets.NewSecret((utils.Hex("8")))),
  54. }
  55. return utils.Validate(r, tps, nil)
  56. }