diff --git a/packages/spill/spill-local/src/cleanup.ts b/packages/spill/spill-local/src/cleanup.ts index 2de7198d96..f108d6b9a1 100644 --- a/packages/spill/spill-local/src/cleanup.ts +++ b/packages/spill/spill-local/src/cleanup.ts @@ -66,6 +66,8 @@ function rootIdentity(path: string, stats: Stats): string { async function hasProtectedAncestors(path: string): Promise { /* v8 ignore next -- POSIX ancestry checks have no Windows ACL equivalent. */ if (process.platform === 'win32' || process.geteuid === undefined) return true + /* v8 ignore start -- Windows takes the return above; POSIX tests exercise + the ancestor ownership and mode policy. */ const currentUid = process.geteuid() let child = path let childStats = await lstat(child) @@ -84,6 +86,7 @@ async function hasProtectedAncestors(path: string): Promise { child = parent childStats = stats } + /* v8 ignore stop */ } /** @@ -136,10 +139,13 @@ async function resolveRoot(path: string, allowSymlink: boolean, warn: WarnFn): P return undefined /* v8 ignore stop */ } + /* v8 ignore start -- Windows has no POSIX ownership or mode rejection path; + POSIX tests exercise both unsafe-directory conditions. */ if (!isTrustedDirectory(stats) || !protectedAncestors) { warnSafely(warn, `spill-local: skipped unsafe root ${canonical}: expected a current-user-owned directory with protected write and ancestor permissions`) return undefined } + /* v8 ignore stop */ return { path: canonical, identity: rootIdentity(canonical, stats) } } diff --git a/packages/spill/spill-local/tests/spill-local.spec.ts b/packages/spill/spill-local/tests/spill-local.spec.ts index 936a3b0f46..1948731bff 100644 --- a/packages/spill/spill-local/tests/spill-local.spec.ts +++ b/packages/spill/spill-local/tests/spill-local.spec.ts @@ -477,6 +477,10 @@ describe('startup cleanup sweep', () => { } }) + it('omits a missing active root', async () => { + expect(await gatherSweepRoots(join(root, 'missing'), () => {}, root)).toEqual([]) + }) + it('skips a root that another POSIX user could replace', async () => { if (process.platform === 'win32') return const unsafeParent = join(root, 'unsafe-parent')