Skip to content

fix: reject missing files under a symlinked directory - #284

Merged
SebTardif merged 2 commits into
mainfrom
fix/improve-mpi-20260928-s0935
Sep 28, 2026
Merged

SebTardif merged 2 commits into
mainfrom
fix/improve-mpi-20260928-s0935

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

Summary

isRealPathInsideWorkspace treated a missing file as a lexical in-workspace path. A directory inside the workspace that is a symlink to an outside directory then looked safe for escape/missing.txt, even though that file would be created outside.

The check now realpaths the nearest existing ancestor and joins the missing suffix before comparing to the workspace. A normal missing file inside the workspace still counts as inside, so preview can report not found. An existing symlink to an outside file stays rejected.

If creating the directory symlink is denied (EPERM, EACCES, ENOTSUP), that extra assertion is skipped and the rest of the test still runs.

Why

Preview refuses paths that resolve outside the workspace. The ENOENT fallback undid that check for any missing name under a symlinked directory.

Verification

  • node --test on isRealPathInsideWorkspace follows symlinks and stays fail-closed (pass, not skipped)
  • npm run check on the product change (unit tests, coverage, vsce package)

Checklist

  • All commits in this pull request are signed off with git commit -s
  • I ran npm run check and it passes
  • I updated docs if user-facing behavior changed
  • I am contributing this work under the repository license (MIT)

isRealPathInsideWorkspace treated ENOENT as a lexical in-workspace path. A directory symlink to outside then allowed escape/missing.txt. Walk to the nearest existing ancestor and realpath that before comparing to the workspace.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
A failed directory symlink used to skip the whole test, including the file-symlink case that already passed. Only EPERM, EACCES, and ENOTSUP skip the extra assertion.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif
SebTardif marked this pull request as ready for review September 28, 2026 16:39
@SebTardif
SebTardif enabled auto-merge (squash) September 28, 2026 16:40
@SebTardif
SebTardif merged commit fb6b2c2 into main Sep 28, 2026
23 checks passed
@SebTardif
SebTardif deleted the fix/improve-mpi-20260928-s0935 branch September 28, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant