fix(aibox): never fall back to deepseek.key for model profile endpoints (H1)
~/.cert/deepseek.key is a DeepSeek-only credential; when a models profile specified its own api_key_env (e.g. MOONSHOT_API_KEY) but the env var was unset, resolve_api_key silently read that file and sent the DeepSeek key as Bearer to a third-party endpoint (cross-vendor credential leak). resolve_api_key gains allow_key_file (default True for the legacy flat api section); create_llm_client passes allow_key_file=profile is None so any profile path raises a clear RuntimeError instead, pointing users to set the env var or use "" for local keyless endpoints. Tests: new TestH1KeyIsolation (4 cases) with a mocked readable deepseek.key proving the profile path errors out while the flat api section still reads the file; full suite 276 passed.
This commit is contained in:
1 parent
58725c8a12
commit
4480bce684
3 files changed
+68
-3
No files matched your search
+1
-1
@@ -548,7 +548,7 @@ AI 可以通过 `update_soul` 工具动态更新 `99_SOUL.md`,通过 `update_i
|
||||
|---|---|
|
||||
| `api_url` | 端点 URL(OpenAI Chat Completions 协议) |
|
||||
| `model` | 该档案使用的模型名 |
|
||||
| `api_key_env` | API Key 环境变量名;**未配置回退 `api.api_key_env`;显式空串 `""` 为本地免密端点**(Ollama/vLLM) |
|
||||
| `api_key_env` | API Key 环境变量名;**未配置回退 `api.api_key_env`;显式空串 `""` 为本地免密端点**(Ollama/vLLM)。档案端点环境变量取不到时**直接报错,绝不回退 `~/.cert/deepseek.key`**——该文件为 DeepSeek 专属凭据,跨厂商复用属于泄漏(key 文件回退仅对无档案的旧 `api` 扁平节生效) |
|
||||
| `reasoning_enabled` | 档案级思考模式开关(缺省回退 `api.reasoning_enabled`) |
|
||||
| `timeout` | 请求超时秒数 |
|
||||
|
||||
|
||||
Reference in new issue
Block a user