Repository navigation
fs: check every path in recursive operations - #67932
Open
ShogunPanda wants to merge 1 commit into
Open
ShogunPanda wants to merge 1 commit into
ShogunPanda wants to merge 1 commit into
Conversation
When the permission model is enabled, fs.cpSync() now uses the per-entry JavaScript copy path instead of the native recursive copy, so every source and destination path is checked, matching fs.cp(). Recursive fs.rmSync() now checks every descendant before removing the tree, and denies the removal if the tree cannot be fully walked. Recursive fs.mkdir(), fs.mkdirSync() and fs.promises.mkdir() check each missing parent directory before creating it. Signed-off-by: Paolo Insogna <paolo@cowtech.it> Assisted-By: OpenAI:GPT-6-Sol <openai/gpt-6-sol>
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67932 +/- ##
==========================================
- Coverage 90.59% 90.58% -0.02%
==========================================
Files 802 802
Lines 286656 286714 +58
Branches 55383 55394 +11
==========================================
+ Hits 259710 259721 +11
- Misses 17058 17094 +36
- Partials 9888 9899 +11
🚀 New features to boost your workflow:
|
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.
When the permission model is enabled, some recursive
node:fsoperations only checked the root path and then walked the tree natively, so their behavior was inconsistent with the equivalent per-path APIs and withfs.cp():fs.cpSync()(recursive, nofilter) now uses the per-entry JavaScript copy path when the permission model is enabled, so every source read and destination write is checked, mirroringfs.cp().fs.rmSync()now checks every descendant before removing the tree, and denies the removal if the tree cannot be fully walked.fs.mkdir(),fs.mkdirSync()andfs.promises.mkdir()now check each missing parent directory before creating it, not only the final path.fs.rm()andfs.promises.rm()are not changed: they already remove entries one by one through the regular per-pathfsoperations, which are checked individually. A test case forfs.promises.rm()is included.Behavior with the permission model disabled is unchanged (the native fast paths are kept).
New tests cover exact grants on paths that do not exist at startup, entries created after startup, relative paths after
process.chdir(), a directory tree that cannot be fully walked, and wildcard-grant controls.Release notes
With
--permission, recursivefs.cpSync(),fs.rmSync()andfs.mkdir()/fs.mkdirSync()now throwERR_ACCESS_DENIEDwhen a descendant, or a parent directory that would be created, is outside the granted paths. Recursivefs.rmSync()also throwsERR_ACCESS_DENIEDwhen it cannot walk the whole tree to check it.