generic.go 1.4 KB

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