Repository navigation
fix(test): keep a developer's live OpenCodex credentials out of the test sandbox - #5830
Conversation
… test sandbox A Windows install stores its data-plane token as a user environment variable, so the sandbox inherited OPENCODEX_API_AUTH_TOKEN from every shell on that machine. installLaunchd then baked the live token into the plist, the byte-identical check failed, and five launchd repair tests failed only on a developer machine. createIsolatedTestEnvironment and the preload now drop OPENCODEX_API_AUTH_TOKEN, OPENCODEX_ADMIN_AUTH_TOKEN, and OCX_API_TOKEN_FILE.
link-compensation and client-link-tunnel asserted 0600 on files Windows protects with NTFS ACLs, where stat reports 0666. The other link tests already guard this the same way.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9628819553
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| writeTestTempOwner(root, baseEnv[TEST_RUN_ID_ENV]); | ||
| const inherited = { ...baseEnv }; | ||
| for (const name of LIVE_INSTALL_CREDENTIAL_ENV) delete inherited[name]; |
There was a problem hiding this comment.
Strip credential keys case-insensitively on Windows
When a Windows environment contains one of these variables with noncanonical casing, such as opencodex_api_auth_token, spreading baseEnv creates an ordinary case-sensitive object and these exact-name deletions leave the credential in isolated.env; runTestLane then passes it to Bun.spawn, where Windows treats it as the same variable and the sandbox can again consume the developer's live token. Filter the copied keys by an uppercased name and cover a mixed-case input in the regression test.
AGENTS.md reference: scripts/AGENTS.md:L14-L17
Useful? React with 👍 / 👎.
Summary
On a Windows machine with OpenCodex installed, the test suite failed tests that pass on the hosted runners. The install stores its data-plane token as a user environment variable (
OPENCODEX_API_AUTH_TOKEN), so every shell on that machine carries it. The test sandbox rewrote HOME and the config directories but passed the rest of the environment through, so tests that assume no credential read the live token instead:installLaunchdbaked it into the plist, and the byte-identical no-op path turned into a bootstrap.createIsolatedTestEnvironment(thebun run testpath) andtests/preload.ts(barebun test) now dropOPENCODEX_API_AUTH_TOKEN,OPENCODEX_ADMIN_AUTH_TOKEN, andOCX_API_TOKEN_FILEfrom the sandbox. The list is exported once asLIVE_INSTALL_CREDENTIAL_ENV. Other inherited variables are unchanged.tests/clients/link-compensation.test.tsandtests/clients/client-link-tunnel.test.tsasserted POSIX mode0600on Windows, where the files are protected by NTFS ACL hardening andstatreports0666. They now skip that check on Windows, the same waylink-storeandclient-link-statealready do.Verification
The CI Windows leg (9 shards,
BUN_TEST_BATCH_SIZE=6, 480 s batches, Bun 1.4.0) was run sequentially on a Windows 11 machine with OpenCodex installed andOPENCODEX_API_AUTH_TOKENset in the user environment:dev04ba23d, 13 unique failures appeared:launchd-repair, 2 incursor-integration-status, 1 inloopback-companion-client-targets, and 2 inclaude-cli.Codex Log Guard inspection > repeat inspection is memoized and invalidated by a write. It passes alone and is the mtime-granularity case AGENTS.md already lists; it is not changed here.bun test tests/ci-workflows/test-runner.test.ts tests/update/update-stop-first.test.ts tests/ci-workflows/test-home-guard.test.ts: 104 pass, including the newdrops the developer's live install credentialscase.bun x tsc --noEmitpasses.Checklist