Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { inspectDesktop3pConfigLibrary, writeDesktop3pConfig } from "../../src/c
import { resolveDesktop3pConfigLibraryPath } from "../../src/claude/desktop-3p-library";
import { resetHardenedStateForTests, setAsyncIcaclsBeltSchedulerForTests, setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests, setNowForTests, setPlatformForTests, windowsSecretAclReapPendingForPath, type IcaclsResult } from "../../src/lib/windows-secret-acl";
import { setSyntheticWindowsPrincipalForTests } from "../../src/lib/windows-user-principal";
import { setWindowsOwnerAclRunnerForTests } from "../../src/lib/windows-owner-acl";
import { writeServiceApiTokenFile } from "../../src/lib/service-secrets";
import type { OcxConfig } from "../../src/types";
import { removeTreeWithRetry } from "../helpers/remove-tree";
Expand Down Expand Up @@ -52,6 +53,9 @@ beforeEach(() => {
setPlatformForTests("win32");
setSyntheticWindowsPrincipalForTests("*S-1-5-21-1-2-3-1001");
setIcaclsRunnerForTests(() => success);
// icacls is mocked, so the real PowerShell owner check must not decide hardening:
// a cold probe can exhaust the 1s ACL budget and refuse before the mocked icacls runs.
setWindowsOwnerAclRunnerForTests(() => ({ success: false, timedOut: false, stdout: "" }));
});
afterEach(async () => {
await paths.flushConfigDirHardeningAndReaps(root);
Expand All @@ -61,6 +65,7 @@ afterEach(async () => {
setAsyncIcaclsBeltSchedulerForTests(null);
setNowForTests(null);
setIcaclsRunnerForTests(null);
setWindowsOwnerAclRunnerForTests(null);
setLocalCaWindowsAclRunnerForTests(null);
setPlatformForTests(null);
setSyntheticWindowsPrincipalForTests(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { inspectDesktop3pConfigLibrary, removeDesktop3pStandardPivot, writeDeskt
import { resolveDesktop3pConfigLibraryPath } from "../../src/claude/desktop-3p-library";
import { resetHardenedStateForTests, setAsyncIcaclsBeltSchedulerForTests, setAsyncIcaclsRunnerForTests, setIcaclsRunnerForTests, setNowForTests, setPlatformForTests, windowsSecretAclReapPendingForPath, type IcaclsResult } from "../../src/lib/windows-secret-acl";
import { setSyntheticWindowsPrincipalForTests } from "../../src/lib/windows-user-principal";
import { setWindowsOwnerAclRunnerForTests } from "../../src/lib/windows-owner-acl";
import { writeServiceApiTokenFile } from "../../src/lib/service-secrets";
import type { OcxConfig } from "../../src/types";
import { removeTreeWithRetry } from "../helpers/remove-tree";
Expand Down Expand Up @@ -44,6 +45,9 @@ beforeEach(() => {
setPlatformForTests("win32");
setSyntheticWindowsPrincipalForTests("*S-1-5-21-1-2-3-1001");
setIcaclsRunnerForTests(() => success);
// icacls is mocked, so the real PowerShell owner check must not decide hardening:
// a cold probe can exhaust the 1s ACL budget and refuse before the mocked icacls runs.
setWindowsOwnerAclRunnerForTests(() => ({ success: false, timedOut: false, stdout: "" }));
});
afterEach(async () => {
await paths.flushConfigDirHardeningAndReaps(root);
Expand All @@ -53,6 +57,7 @@ afterEach(async () => {
setAsyncIcaclsBeltSchedulerForTests(null);
setNowForTests(null);
setIcaclsRunnerForTests(null);
setWindowsOwnerAclRunnerForTests(null);
setLocalCaWindowsAclRunnerForTests(null);
setPlatformForTests(null);
setSyntheticWindowsPrincipalForTests(null);
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/stop-restore-history-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ writeFileSync(backup, JSON.stringify({ version: 1, stateDbPath: canonicalDb, ent
const lockChecks: { phase: string; config: boolean; history: boolean }[] = [];
if (mode === "sync" && ownership === "standalone") {
const identity = await import("../../src/codex/user-identity");
const historyLockPath = identity.resolveCodexHistorySerializationDatabasePath(identity.resolveEffectiveUserIdentity(), codex, canonicalDb);
// Production locks the canonical CODEX_HOME spelling; macOS temp aliases (/var vs /private/var) hash differently.
const historyLockPath = identity.resolveCodexHistorySerializationDatabasePath(identity.resolveEffectiveUserIdentity(), realpathSync.native(codex), canonicalDb);
function held(path: string): boolean {
const probe = new Database(path);
try { probe.exec("PRAGMA busy_timeout = 0; BEGIN IMMEDIATE; ROLLBACK"); return false; }
Expand Down
Loading