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
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 287061 +405
Branches 55383 55443 +60
==========================================
+ Hits 259710 260043 +333
- Misses 17058 17119 +61
- Partials 9888 9899 +11
🚀 New features to boost your workflow:
|
ShogunPanda
force-pushed
the
fs-recursive-permission-checks
branch
from
December 3, 2026 08:02
62b5a72 to
357b0dd
Compare
Member
|
@ShogunPanda codecov reports that some lines needs more testing, can you add? |
Collaborator
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. Assisted-By: OpenAI GPT-6 Sol <openai/gpt-6-sol> Signed-off-by: Paolo Insogna <paolo@cowtech.it>
ShogunPanda
force-pushed
the
fs-recursive-permission-checks
branch
from
December 3, 2026 18:28
357b0dd to
c554efa
Compare
Collaborator
Collaborator
RafaelGSS
requested changes
Dec 4, 2026
RafaelGSS
left a comment
Member
There was a problem hiding this comment.
Can we add --permission-audit variants of these tests?
FYI isEnabled() is also true in audit mode
| @@ -1834,6 +1834,33 @@ static void ClearReadOnlyAttributeW(const std::filesystem::path& path, | |||
| } | |||
| #endif | |||
|
|
|||
| static std::optional<std::string> DeniedRmPath( | |||
Member
There was a problem hiding this comment.
This denies under --permission-audit. warning_only() is only checked for the per-entry case, so a tree that can't be walked still throws
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.