gitleaks.toml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Gitleaks config — supplements the default ruleset with project-specific patterns.
  2. # Default rules already catch sk-* (OpenAI), ghp_*, AKIA*, etc.
  3. # Here we add China-side providers + project-specific allowlists.
  4. [extend]
  5. # Inherit gitleaks' built-in default rule set
  6. useDefault = true
  7. # ──────────────────────────────────────────────
  8. # Project-specific rules
  9. # ──────────────────────────────────────────────
  10. [[rules]]
  11. id = "siliconflow-api-key"
  12. description = "SiliconFlow API key (硅基流动) — sk-{40+ chars}"
  13. regex = '''sk-[a-z0-9]{40,}'''
  14. keywords = ["siliconflow", "SILICONFLOW_API_KEY"]
  15. [[rules]]
  16. id = "dashscope-api-key"
  17. description = "Aliyun DashScope (百炼) — sk-{32}"
  18. regex = '''sk-[a-f0-9]{32}'''
  19. keywords = ["dashscope", "DASHSCOPE_API_KEY", "bailian"]
  20. [[rules]]
  21. id = "amap-mcp-key"
  22. description = "Amap MCP key (高德地图) — 32-char hex"
  23. regex = '''(AMAP_MCP_KEY|amap.*key)['"\s:=]+[a-f0-9]{32}'''
  24. keywords = ["amap", "AMAP_MCP_KEY", "高德"]
  25. [[rules]]
  26. id = "deepseek-api-key"
  27. description = "DeepSeek API key — sk-{32}"
  28. regex = '''sk-[a-zA-Z0-9]{32}'''
  29. keywords = ["deepseek", "DEEPSEEK_API_KEY"]
  30. [[rules]]
  31. id = "zhipu-api-key"
  32. description = "Zhipu (GLM) API key"
  33. regex = '''[a-f0-9]{32}\.[a-zA-Z0-9]{16}'''
  34. keywords = ["zhipu", "ZHIPU_API_KEY", "智谱"]
  35. [[rules]]
  36. id = "moonshot-api-key"
  37. description = "Moonshot (Kimi) API key — sk-{48+}"
  38. regex = '''sk-[a-zA-Z0-9]{48,}'''
  39. keywords = ["moonshot", "MOONSHOT_API_KEY", "月之暗面"]
  40. # ──────────────────────────────────────────────
  41. # Allowlist (false positives + safe references)
  42. # ──────────────────────────────────────────────
  43. [allowlist]
  44. description = "Test fixtures, doc placeholders, and template files"
  45. paths = [
  46. '''.*\.env\.template$''',
  47. '''.*\.env\.example$''',
  48. '''.*test.*\.(py|ts|js|yml)$''',
  49. '''.*tests/.*''',
  50. '''.*fixtures?/.*''',
  51. '''.*/MEMORY\.md$''', # session memory may include token-shaped strings as docs
  52. # API doc files — full of curl examples with "ap_your_key" / "ap_xxx..." placeholders
  53. '''docs/api\.md$''',
  54. '''docs/usage-guide\.md$''',
  55. '''docs/.*-guide\.md$''', # 任何 *-guide.md 文档(同样多 curl 示例)
  56. ]
  57. regexTarget = "match"
  58. regexes = [
  59. '''<your-key>''',
  60. '''<set-via-[A-Z_]+-env-var>''',
  61. '''\$\{[A-Z_]+_API_KEY\}''',
  62. '''YOUR_API_KEY''',
  63. '''YOUR_TOKEN''',
  64. '''your_(key|token|api_key|secret)''',
  65. '''dummy[_-]?key''',
  66. '''fake[_-]?key''',
  67. '''sk-xxxx+''',
  68. '''ap_your_key''', # agentpaas 文档占位符
  69. '''ap_[a-z0-9]+\.\.\.''', # 截断式样例 (ap_a1b2c3d4e5f6...)
  70. '''Bearer ap_your''', # 出现在 curl Authorization 头
  71. '''Bearer YOUR_''', # 通用 README 写法
  72. ]