Multiplayer agent harness for work.
Stop masking execute output with forced-egress git config values (#2442)
Regan Bell28bf149b53b2
diff --git a/src/sandbox/sandbox-env.ts b/src/sandbox/sandbox-env.tsindex 30dd2e0c0..e93fff2dd 100644--- a/src/sandbox/sandbox-env.ts+++ b/src/sandbox/sandbox-env.ts@@ -35,7 +35,7 @@ export function forceThroughProxyEnv(const u = new URL(egressProxyUrl);const url = `${u.protocol}//x:${token}@${u.host}`;const noProxy = "localhost,127.0.0.1,::1";- const env: Record<string, string> = {+ return {...base,HTTPS_PROXY: url,HTTP_PROXY: url,@@ -43,13 +43,8 @@ export function forceThroughProxyEnv(https_proxy: url,http_proxy: url,no_proxy: noProxy,+ GIT_HTTP_PROXY_AUTHMETHOD: "basic",};- const count = Number(base.GIT_CONFIG_COUNT);- const index = Number.isSafeInteger(count) && count > 0 ? count : 0;- env[`GIT_CONFIG_KEY_${index}`] = "http.proxyAuthMethod";- env[`GIT_CONFIG_VALUE_${index}`] = "basic";- env.GIT_CONFIG_COUNT = String(index + 1);- return env;}export function proxyExportPrefix(handle: SandboxHandle): string {diff --git a/src/security/secret-masking.ts b/src/security/secret-masking.tsindex be73b7f75..c930dcf4e 100644--- a/src/security/secret-masking.ts+++ b/src/security/secret-masking.ts@@ -9,6 +9,7 @@ const NON_SECRET_ENV_KEYS = new Set(["PYTHONUNBUFFERED","NO_PROXY","no_proxy",+ "GIT_HTTP_PROXY_AUTHMETHOD",]);const MIN_MASKABLE_LENGTH = 8;diff --git a/test/modal-sandbox.test.ts b/test/modal-sandbox.test.tsindex 1f1c1e74c..dac4580be 100644--- a/test/modal-sandbox.test.ts+++ b/test/modal-sandbox.test.ts@@ -113,7 +113,7 @@ test("force-through proxy env is set when a proxy url and token are present", as"secret",);const h = await s.provision(layers, { egressToken: token });- const r = await s.run(h, "echo PROXY=$HTTPS_PROXY; git config --get http.proxyAuthMethod");+ const r = await s.run(h, "echo PROXY=$HTTPS_PROXY; echo $GIT_HTTP_PROXY_AUTHMETHOD");assert.match(r.stdout, /PROXY=https?:\/\/[^ ]*proxy\.example\.com/);assert.match(r.stdout, /^basic$/m);});diff --git a/test/secret-masking.test.ts b/test/secret-masking.test.tsindex 39e930e57..8b600ae26 100644--- a/test/secret-masking.test.ts+++ b/test/secret-masking.test.ts@@ -6,6 +6,7 @@ import {MaskedExecutionError,executionSecretEnv,} from "../src/security/secret-masking.ts";+import { forceThroughProxyEnv } from "../src/sandbox/sandbox-env.ts";const SECRET = "ghp_secretvalue12345";@@ -111,3 +112,12 @@ test("MaskedExecutionError keeps the original error class, code and masked stackassert.match(masked.stack ?? "", /^TypeError: connect failed for <redacted:credential>\n\s+at /);assert.doesNotMatch(masked.stack ?? "", /s3cr3t-value/);});++test("forced-egress env masks the proxy token without rewriting ordinary output", () => {+ const token = "egress-token-value-123";+ const env = forceThroughProxyEnv("https://proxy.example.com", token, {});+ const mask = createExactSecretValueMasker(Object.values(executionSecretEnv(env)));+ const output = "0f1e2d3c-4b5a-1111-basic\n[exit 0]";+ assert.equal(mask(output), output);+ assert.equal(mask(env.HTTPS_PROXY!), "<redacted:credential>");+});diff --git a/test/sprites-sandbox.test.ts b/test/sprites-sandbox.test.tsindex a51de01f3..1b27a054e 100644--- a/test/sprites-sandbox.test.ts+++ b/test/sprites-sandbox.test.ts@@ -270,17 +270,18 @@ test("force-through makes git send proxy credentials up front, keeping turn gitegressToken: await proxyToken(),env: { GIT_CONFIG_COUNT: "1", GIT_CONFIG_KEY_0: "user.name", GIT_CONFIG_VALUE_0: "Turn User" },});- const r = await s.run(h, "git config --get http.proxyAuthMethod; git config --get user.name");+ const r = await s.run(h, "echo $GIT_HTTP_PROXY_AUTHMETHOD; git config --get user.name");assert.equal(r.code, 0, r.stderr);assert.deepEqual(r.stdout.trim().split("\n"), ["basic", "Turn User"]);+ assert.deepEqual(+ [h.env?.GIT_CONFIG_COUNT, h.env?.GIT_CONFIG_KEY_0, h.env?.GIT_CONFIG_VALUE_0],+ ["1", "user.name", "Turn User"],+ );});-test("git config from the proxy env stays off when egress is not forced", async () => {+test("git proxy auth from the proxy env stays off when egress is not forced", async () => {const h = await sandbox.provision(layers, { egressToken: "ignored" });- const r = await sandbox.run(- h,- "GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 git config --get http.proxyAuthMethod || echo unset",- );+ const r = await sandbox.run(h, 'echo "${GIT_HTTP_PROXY_AUTHMETHOD:-unset}"');assert.equal(r.stdout.trim(), "unset");});