generic.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/config"
  4. )
  5. func GenericCredential() *config.Rule {
  6. // define rule
  7. r := config.Rule{
  8. RuleID: "generic-api-key",
  9. Description: "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
  10. Regex: generateSemiGenericRegex([]string{
  11. "key",
  12. "api",
  13. "token",
  14. "secret",
  15. "client",
  16. "passwd",
  17. "password",
  18. "auth",
  19. "access",
  20. }, `[0-9a-z\-_.=]{10,150}`, true),
  21. Keywords: []string{
  22. "key",
  23. "api",
  24. "token",
  25. "secret",
  26. "client",
  27. "passwd",
  28. "password",
  29. "auth",
  30. "access",
  31. },
  32. Entropy: 3.5,
  33. Allowlist: config.Allowlist{
  34. StopWords: DefaultStopWords,
  35. },
  36. }
  37. // validate
  38. tps := []string{
  39. generateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"),
  40. generateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
  41. `"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
  42. `"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
  43. }
  44. fps := []string{
  45. `client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.client-vpn-endpoint.id`,
  46. `password combination.
  47. R5: Regulatory--21`,
  48. }
  49. return validate(r, tps, fps)
  50. }