Files
hyperframes/packages/cli/scripts/test-file-home.mjs
T
Xuanru Li ca25558083 fix(cli): enforce private cache install paths (#7981)
* fix(cli): cache installs only use folders the current user owns

Code the CLI downloads or builds into its cache (Chrome, the TTS script,
audio helpers, whisper.cpp, OpenCV, the Lambda handler, optional packages)
now goes into folders created by the current user with owner-only write,
and each installed file is checked again before it is returned.

- A cache root that other accounts can add entries to, sticky or not, is
  no longer used for code; the per-user cache is used instead.
- The ownership check reads links rather than following them, and a link
  that leads out of the cache root is not trusted.

* fix(cli): validate cache ancestry before filesystem side effects

* fix(core): check links before parent path segments

* fix(cli): validate cached libraries and clarify private parent requirements

* fix(cli): use the shared staging directory helper for Apple builds
2026-11-16 23:28:26 +00:00

15 lines
602 B
JavaScript

// Each test file gets a home of its own: per-user state such as the render lock is never
// shared by test files running at the same time, so one file's render cannot make another's wait.
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterAll } from "vitest";
const previousUmask = process.umask(0o022);
const home = mkdtempSync(join(tmpdir(), "hf-test-file-home-"));
process.env.HOME = process.env.USERPROFILE = home;
afterAll(() => {
process.umask(previousUmask);
rmSync(home, { recursive: true, force: true });
});