Repository navigation
fix(cli): enforce project-root realpath containment in format - #2486
Open
rafal-hawrylak wants to merge 2 commits into
Open
rafal-hawrylak wants to merge 2 commits into
rafal-hawrylak wants to merge 2 commits into
Conversation
dataform format now resolves every matched file to its real path and refuses files outside the project directory. Before this, symlinks under definitions or includes and --actions patterns containing parent-directory segments could read or overwrite files outside the project. Behavior change: projects that symlink files from outside the project directory now get a per-file error and exit code 1 from dataform format. The containment check from ModuleResolver moves to common/vm/path_utils so both callers share it.
rafal-hawrylak
requested review from
Ford544,
apilaskowski and
mbiernacik
and removed request for
a team
November 24, 2026 14:25
mbiernacik
approved these changes
Nov 24, 2026
apilaskowski
approved these changes
Nov 24, 2026
| try { | ||
| const filePath = path.resolve(argv.projectDir, filename); | ||
| // Symbolic links and ".." patterns must not reach files outside the project. | ||
| if (!isRealPathContained(fs.realpathSync(filePath), realProjectRoot)) { |
Collaborator
There was a problem hiding this comment.
Should this also honor the project's allowedExternalPaths, like ModuleResolver.isPathContained? Otherwise projects that compile fine with shared external includes now fail format. Separately: consider resolving once and using the real path for the read/write too, so a symlink swap between the check and formatFile can't redirect the write.
This branch has not been deployed
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.
dataform format now resolves every matched file to its real path and refuses files outside the project directory. Before this, symlinks under definitions or includes and --actions patterns containing parent-directory segments could read or overwrite files outside the project.
Behavior change: projects that symlink files from outside the project directory now get a per-file error and exit code 1 from dataform format.
The containment check from ModuleResolver moves to common/vm/path_utils so both callers share it.