




















@@ -347,6 +347,89 @@ describe("buildGatewayInstallPlan", () => {
347347expect(plan.environment.OPENCLAW_SERVICE_MANAGED_ENV_KEYS).toBeUndefined();
348348});
349349350+it("allows safe inherited passEnv names while blocking dangerous exec SecretRef env", async () => {
351+mockNodeGatewayPlanFixture({
352+serviceEnvironment: {
353+OPENCLAW_PORT: "3000",
354+},
355+});
356+357+const warn = vi.fn();
358+const plan = await buildGatewayInstallPlan({
359+env: isolatedPlanEnv({
360+BASH_ENV: "/tmp/openclaw-test-bashenv",
361+XDG_CONFIG_HOME: "/tmp/openclaw-test-xdg-home",
362+XDG_CONFIG_DIRS: "/etc/xdg:/opt/xdg",
363+GH_TOKEN: "gh-test-token",
364+AWS_ACCESS_KEY_ID: "aws-access-key",
365+DOCKER_HOST: "tcp://docker.example.test:2376",
366+NODE_TLS_REJECT_UNAUTHORIZED: "0",
367+}),
368+port: 3000,
369+runtime: "node",
370+ warn,
371+config: {
372+secrets: {
373+providers: {
374+onepassword: {
375+source: "exec",
376+command: "/usr/bin/op",
377+args: ["read", "op://Private/Discord/password"],
378+passEnv: [
379+"HOME",
380+"BASH_ENV",
381+"XDG_CONFIG_HOME",
382+"XDG_CONFIG_DIRS",
383+"GH_TOKEN",
384+"AWS_ACCESS_KEY_ID",
385+"DOCKER_HOST",
386+"NODE_TLS_REJECT_UNAUTHORIZED",
387+],
388+allowInsecurePath: true,
389+},
390+},
391+},
392+channels: {
393+discord: {
394+token: { source: "exec", provider: "onepassword", id: "value" },
395+},
396+},
397+},
398+});
399+400+expect(plan.environment.HOME).toBe(isolatedHome);
401+expect(plan.environment.BASH_ENV).toBeUndefined();
402+expect(plan.environment.XDG_CONFIG_HOME).toBeUndefined();
403+expect(plan.environment.XDG_CONFIG_DIRS).toBeUndefined();
404+expect(plan.environment.GH_TOKEN).toBeUndefined();
405+expect(plan.environment.AWS_ACCESS_KEY_ID).toBeUndefined();
406+expect(plan.environment.DOCKER_HOST).toBeUndefined();
407+expect(plan.environment.NODE_TLS_REJECT_UNAUTHORIZED).toBeUndefined();
408+expect(warn).not.toHaveBeenCalledWith(
409+'Exec SecretRef passEnv ref "HOME" blocked by host-env security policy',
410+"Config SecretRef",
411+);
412+expect(warn).toHaveBeenCalledWith(
413+expect.stringContaining("XDG_CONFIG_HOME"),
414+"Config SecretRef",
415+);
416+expect(warn).toHaveBeenCalledWith(
417+expect.stringContaining("XDG_CONFIG_DIRS"),
418+"Config SecretRef",
419+);
420+expect(warn).toHaveBeenCalledWith(expect.stringContaining("BASH_ENV"), "Config SecretRef");
421+expect(warn).toHaveBeenCalledWith(expect.stringContaining("GH_TOKEN"), "Config SecretRef");
422+expect(warn).toHaveBeenCalledWith(
423+expect.stringContaining("AWS_ACCESS_KEY_ID"),
424+"Config SecretRef",
425+);
426+expect(warn).toHaveBeenCalledWith(expect.stringContaining("DOCKER_HOST"), "Config SecretRef");
427+expect(warn).toHaveBeenCalledWith(
428+expect.stringContaining("NODE_TLS_REJECT_UNAUTHORIZED"),
429+"Config SecretRef",
430+);
431+});
432+350433it("does not include passEnv values for unused exec SecretRef providers", async () => {
351434mockNodeGatewayPlanFixture({
352435serviceEnvironment: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。