From 4724015e3e9e6c61fcc255c4588aff2e09498cab Mon Sep 17 00:00:00 2001 From: JUN <243035832+lidge-jun@users.noreply.github.com> Date: Sat, 31 Oct 2026 04:31:33 +0900 Subject: [PATCH 1/2] test(claude): report the hardened local-CA ACL in the first-party apply suite The local-CA ACL inspection spawns PowerShell under the shared 30 s principal budget, which a loaded hosted Windows runner exhausted (windows 1/11 of lane=all run 41073826161: local_ca_path_unsafe after 30095 ms). This suite covers first-party apply; inject the private ACL for the real current SID through the existing seam. Native inspection stays covered by claude-intercept-local-ca-windows.test.ts. --- .../claude-desktop-first-party.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/claude-integration/claude-desktop-first-party.test.ts b/tests/claude-integration/claude-desktop-first-party.test.ts index 3ab33edae87..80063b21f7a 100644 --- a/tests/claude-integration/claude-desktop-first-party.test.ts +++ b/tests/claude-integration/claude-desktop-first-party.test.ts @@ -25,6 +25,8 @@ import { firstPartyDesired } from "../../src/claude/first-party-settings"; import type { OcxConfig } from "../../src/types"; import { removeTreeWithRetry } from "../helpers/remove-tree"; import { flushConfigDirHardeningAndReaps } from "../../src/config/paths"; +import { setLocalCaWindowsAclRunnerForTests } from "../../src/claude/intercept/local-ca-windows"; +import { resolveCurrentWindowsPrincipal } from "../../src/lib/windows-user-principal"; let root = ""; let lifecycleLock: ReturnType; @@ -65,6 +67,16 @@ function expectStatus(result: { status: number; body: unknown }, status: number) beforeEach(() => { root = mkdtempSync(join(tmpdir(), "ocx-desktop-1p-")); lifecycleLock = isolateClientLifecycleLock(root); + // The local-CA ACL inspection spawns PowerShell under the shared 30 s principal-lookup budget, + // which loaded hosted Windows runners can exhaust (local_ca_path_unsafe). This file tests + // first-party apply, not that inspection (claude-intercept-local-ca-windows.test.ts runs it + // natively), so report the private ACL the hardener produces for the real current SID. + if (process.platform === "win32") { + const sid = resolveCurrentWindowsPrincipal(30_000).replace(/^\*/, ""); + setLocalCaWindowsAclRunnerForTests(() => ({ success: true, exitCode: 0, timedOut: false, stdout: JSON.stringify({ + owner: sid, protected: true, rules: [{ sid, type: 0, rights: 2032127 }], + }) })); + } library = join(root, "desktop-library"); claudeDir = join(root, "claude"); for (const key of ENV_KEYS) previous[key] = process.env[key]; @@ -76,6 +88,7 @@ beforeEach(() => { afterEach(async () => { await flushConfigDirHardeningAndReaps(root); + setLocalCaWindowsAclRunnerForTests(null); lifecycleLock.restore(); for (const key of ENV_KEYS) { if (previous[key] === undefined) delete process.env[key]; From 96eee6ef155f841c04cabb82d9494a4dfe7b31e9 Mon Sep 17 00:00:00 2001 From: JUN <243035832+lidge-jun@users.noreply.github.com> Date: Sat, 31 Oct 2026 04:35:37 +0900 Subject: [PATCH 2/2] test(claude): read the cached SID inside the injected ACL runner and reset it in finally Review: no separate principal lookup before the environment snapshot; reset the seam even if the hardening drain throws. --- .../claude-desktop-first-party.test.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/claude-integration/claude-desktop-first-party.test.ts b/tests/claude-integration/claude-desktop-first-party.test.ts index 80063b21f7a..1595da1f9b4 100644 --- a/tests/claude-integration/claude-desktop-first-party.test.ts +++ b/tests/claude-integration/claude-desktop-first-party.test.ts @@ -67,16 +67,6 @@ function expectStatus(result: { status: number; body: unknown }, status: number) beforeEach(() => { root = mkdtempSync(join(tmpdir(), "ocx-desktop-1p-")); lifecycleLock = isolateClientLifecycleLock(root); - // The local-CA ACL inspection spawns PowerShell under the shared 30 s principal-lookup budget, - // which loaded hosted Windows runners can exhaust (local_ca_path_unsafe). This file tests - // first-party apply, not that inspection (claude-intercept-local-ca-windows.test.ts runs it - // natively), so report the private ACL the hardener produces for the real current SID. - if (process.platform === "win32") { - const sid = resolveCurrentWindowsPrincipal(30_000).replace(/^\*/, ""); - setLocalCaWindowsAclRunnerForTests(() => ({ success: true, exitCode: 0, timedOut: false, stdout: JSON.stringify({ - owner: sid, protected: true, rules: [{ sid, type: 0, rights: 2032127 }], - }) })); - } library = join(root, "desktop-library"); claudeDir = join(root, "claude"); for (const key of ENV_KEYS) previous[key] = process.env[key]; @@ -84,11 +74,23 @@ beforeEach(() => { process.env.OPENCODEX_CLAUDE_DESKTOP_CONFIG_DIR = library; process.env.CLAUDE_CONFIG_DIR = claudeDir; writeFileSync(join(root, "config.json"), JSON.stringify(config())); + // The local-CA ACL inspection spawns PowerShell under the shared 30 s principal-lookup budget, + // which a loaded hosted Windows runner can exhaust (local_ca_path_unsafe). This file tests + // first-party apply; claude-intercept-local-ca.test.ts runs the native inspection. Report the + // private ACL for the current SID, which production resolves (and caches) before this runner. + if (process.platform === "win32") { + setLocalCaWindowsAclRunnerForTests((_path, timeoutMs) => { + const sid = resolveCurrentWindowsPrincipal(timeoutMs).replace(/^\*/, ""); + return { success: true, exitCode: 0, timedOut: false, stdout: JSON.stringify({ + owner: sid, protected: true, rules: [{ sid, type: 0, rights: 2032127 }], + }) }; + }); + } }); afterEach(async () => { - await flushConfigDirHardeningAndReaps(root); - setLocalCaWindowsAclRunnerForTests(null); + try { await flushConfigDirHardeningAndReaps(root); } + finally { setLocalCaWindowsAclRunnerForTests(null); } lifecycleLock.restore(); for (const key of ENV_KEYS) { if (previous[key] === undefined) delete process.env[key];