Key 修法:agent shell 不再继承密钥类环境变量
- 实弹证实:默认配置下 agent shell 继承 server 进程 env,local 与 docker 两路都能拿到共享 relay key(v3 标记文件法双路 PRESENT)。 - 修法用 codex 原生 shell_environment_policy.exclude:server 自己 的中转调用走进程 env(env_key),不受 shell 策略影响,两者可 分开;inherit 保持默认 all,PATH、代理变量等不动;gh 用文件 登录不用 env,故不排 *_TOKEN。 - host.py Server._start 经 _server_command 统一加 -c 旗标,local 与 docker 共用一处,覆盖两路;-c 语法已用本机二进制实测 (合法值启动正常,非法值立即报 invalid shell environment policy 退出)。 - 测试:新增 _server_command 断言;全量 host 65、cloud 668 (4 跳过)、deploy 19 全过
This commit is contained in:
1 parent
7e081211db
commit
89c8fb1a79
2 files changed
+47
-1
No files matched your search
@@ -52,6 +52,21 @@ class HostPureFunctionsTest(unittest.TestCase):
|
||||
missing = os.path.join(tmp, "missing.json")
|
||||
self.assertEqual(host._load_config_file(missing), {})
|
||||
|
||||
def test_server_command_excludes_secrets_from_agent_shell(self):
|
||||
cmd = host._server_command("/usr/bin/codex")
|
||||
self.assertEqual(cmd[0], "/usr/bin/codex")
|
||||
self.assertEqual(cmd[-1], "app-server")
|
||||
self.assertIn("-c", cmd)
|
||||
flag = cmd[cmd.index("-c") + 1]
|
||||
self.assertTrue(
|
||||
flag.startswith("shell_environment_policy.exclude="), flag)
|
||||
excluded = json.loads(
|
||||
flag.split("=", 1)[1])
|
||||
for name in ("XCM_API_KEY", "CLOUD_DB_PASSWORD",
|
||||
"GITHUB_OAUTH_CLIENT_SECRET", "GITHUB_WEBHOOK_SECRET",
|
||||
"*_KEY", "*_SECRET", "*_PASSWORD"):
|
||||
self.assertIn(name, excluded)
|
||||
|
||||
|
||||
def _init_git_repo(tmp):
|
||||
subprocess.run(["git", "init", "-q"], cwd=tmp, check=True)
|
||||
|
||||
Reference in new issue
Block a user