Skip to content

Vitest 1.6.0 upgrade breaks sandboxing the filesystem from tests #5767

@mixedCase

Description

@mixedCase

Describe the bug

The Vitest 1.5.3 -> 1.6.0 upgrade broke our CI test job. It's now requesting to mkdir inside /tmp a folder with a hash-derived name.

We (partially) try to apply the Google test size restrictions disabling filesystem writes via sandboxing, which so far has worked well because all attempted writes were able to be disabled by running vitest run --outputFile=false --cache=false but the changes in this commit to the rpc.ts file in the pool implementations (we use vmThreads) doesn't seem like it allows disabling the temporary folder it creates.

We've previously attempted to implement these limitations in a Vitest custom environment and were unable to. Could this new folder creation be disabled in an upcoming version, or is there another way to implement these restrictions that plays better with Vitest expectations? Thanks

Reproduction

This is the abridged version of what we do in macOS:

sandbox_rules="
  (version 1)
  (deny default)
  (deny network*)
  (allow file-read*)
  (deny file-write*)
  (allow process-exec*)
  (allow process-fork)
  (allow sysctl-read)
  (allow ipc-posix-shm)
"
sandbox-exec -p "$sandbox_rules" /usr/bin/env pnpm exec vitest run --outputFile=false --pool=vmThreads --cache=false

System Info

$ npx envinfo --system --npmPackages '{vitest,@vitest/*,vite,@vitejs/*}' --binaries --browsers

  System:
    OS: macOS 14.4.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 469.91 MB / 32.00 GB
    Shell: 5.2.26 - /nix/store/pq42p95pl3fz2p4cy4qcmwsnlj5804kb-bash-interactive-5.2p26/bin/bash
  Binaries:
    Node: 20.11.1 - /nix/store/kwnl5cxqpa30alxwdksrjnzjrj4wrww3-nodejs-20.11.1/bin/node
    npm: 10.2.4 - /nix/store/kwnl5cxqpa30alxwdksrjnzjrj4wrww3-nodejs-20.11.1/bin/npm
    pnpm: 8.15.5 - /nix/store/gj6fs8nbmam0gnvn653wy5ini3zmf5w7-pnpm-8.15.5/bin/pnpm
    bun: 1.0.13 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 125.1.66.110
    Safari: 17.4.1
  npmPackages:
    @vitest/coverage-v8: ^1.4.0 => 1.6.0
    vite: ^5.1.6 => 5.2.11
    vitest: 1.6.0 => 1.6.0

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-significantHigh priority enhancement (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions