generic.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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: "Generic API Key",
  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}`),
  21. SecretGroup: 1,
  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. generateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"),
  41. 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 validate(r, tps, fps)
  51. }