fix: reject missing files under a symlinked directory - #284
Merged
Merged
Conversation
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
marked this pull request as ready for review
September 28, 2026 16:39
SebTardif
enabled auto-merge (squash)
September 28, 2026 16:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isRealPathInsideWorkspacetreated 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 forescape/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 --testonisRealPathInsideWorkspace follows symlinks and stays fail-closed(pass, not skipped)npm run checkon the product change (unit tests, coverage,vsce package)Checklist
git commit -snpm run checkand it passes