gcp.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package rules
  2. import (
  3. "regexp"
  4. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  5. "github.com/zricethezav/gitleaks/v8/config"
  6. )
  7. // TODO this one could probably use some work
  8. func GCPServiceAccount() *config.Rule {
  9. // define rule
  10. r := config.Rule{
  11. Description: "Google (GCP) Service-account",
  12. RuleID: "gcp-service-account",
  13. Regex: regexp.MustCompile(`\"type\": \"service_account\"`),
  14. Keywords: []string{`\"type\": \"service_account\"`},
  15. }
  16. // validate
  17. tps := []string{
  18. `"type": "service_account"`,
  19. }
  20. return validate(r, tps, nil)
  21. }
  22. func GCPAPIKey() *config.Rule {
  23. // define rule
  24. r := config.Rule{
  25. RuleID: "gcp-api-key",
  26. Description: "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.",
  27. Regex: generateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`, true),
  28. Keywords: []string{
  29. "AIza",
  30. },
  31. }
  32. // validate
  33. tps := []string{
  34. generateSampleSecret("gcp", secrets.NewSecret(`AIza[0-9A-Za-z\\-_]{35}`)),
  35. }
  36. return validate(r, tps, nil)
  37. }