generic.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }, `[0-9a-z\-_.=]{10,150}`),
  20. SecretGroup: 1,
  21. Keywords: []string{
  22. "key",
  23. "api",
  24. "token",
  25. "secret",
  26. "client",
  27. "passwd",
  28. "password",
  29. "auth",
  30. },
  31. Entropy: 3.5,
  32. Allowlist: config.Allowlist{
  33. StopWords: DefaultStopWords,
  34. },
  35. }
  36. // validate
  37. tps := []string{
  38. generateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"),
  39. generateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
  40. `"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
  41. `"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
  42. }
  43. fps := []string{
  44. `client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.client-vpn-endpoint.id`,
  45. `password combination.
  46. R5: Regulatory--21`,
  47. }
  48. return validate(r, tps, fps)
  49. }