generic.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. Allowlists: []config.Allowlist{
  35. {
  36. StopWords: DefaultStopWords,
  37. },
  38. },
  39. }
  40. // validate
  41. tps := []string{
  42. utils.GenerateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"), //gitleaks:allow
  43. utils.GenerateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
  44. `"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
  45. `"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
  46. }
  47. fps := []string{
  48. `client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.client-vpn-endpoint.id`,
  49. `password combination.
  50. R5: Regulatory--21`,
  51. }
  52. return utils.Validate(r, tps, fps)
  53. }