Repository navigation
src: resolve watched path once in FSEventWrap - #67646
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:
|
ShogunPanda
force-pushed
the
fs-watch-store-resolved-path
branch
from
November 20, 2026 10:16
4de050b to
f7ec6a0
Compare
ShogunPanda
force-pushed
the
fs-watch-store-resolved-path
branch
from
November 20, 2026 10:26
f7ec6a0 to
f562b6f
Compare
`FSEventWrap::Start()` checked the read scope on the path as it was passed in, then started the watch on the same string, and later used it again to check the entries reported by libuv. A relative path or a symbolic link could resolve differently at each of those steps, for example after `process.chdir()` or when the link was replaced. Resolve the path to its canonical form once, check the read scope on it, and use the same path to start the watch and to check the reported entries. A path whose canonical form is not granted now throws `ERR_ACCESS_DENIED` when the watch starts, including a `..` that follows a symbolic link. On macOS, a path below `/private/var`, `/private/tmp` or `/private/etc` is also accepted if the same path spelled with `/var`, `/tmp` or `/etc` is granted. No other symbolic link is followed outside of the granted paths, and the grants themselves are not changed. Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol> Signed-off-by: Paolo Insogna <paolo@cowtech.it>
ShogunPanda
force-pushed
the
fs-watch-store-resolved-path
branch
from
November 20, 2026 10:34
f562b6f to
8df2191
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67646 +/- ##
==========================================
- Coverage 90.71% 90.71% -0.01%
==========================================
Files 801 801
Lines 280906 280938 +32
Branches 54249 54246 -3
==========================================
+ Hits 254832 254841 +9
- Misses 16246 16258 +12
- Partials 9828 9839 +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.
FSEventWrap::Start()checked the read scope on the path as it was passed in, started the watch on the same string, and later used it again to check the entries reported by libuv. A relative path or a symbolic link could resolve differently at each of those steps, for example afterprocess.chdir()or when the link was replaced.Resolve the path to its canonical form once, check the read scope on it, and use the same path to start the watch and to check the reported entries.
Behavior changes when the permission model is enabled, limited to
fs.watch()andfs.promises.watch():ERR_ACCESS_DENIEDwhen the watch starts. This includes a symbolic link in a granted directory that points elsewhere, a granted path that goes through a symbolic link outside of the granted scope, and a..that follows a symbolic link. Before, these were accepted and the names of the reported entries were dropped./private/var,/private/tmpor/private/etcis also accepted if the same path spelled with/var,/tmpor/etcis granted, and the link really resolves there. No other symbolic link is followed outside of the granted paths.The grants themselves, and every other API, are unchanged. Documented in
doc/api/permissions.md.Testing: rewrote
test/parallel/test-permission-fs-watch-resolved-path.js, with no timers; it fails without the change.test-permission-*,test-fs-watch*andtest-fs-promises-watch*pass, as do cpplint, clang-format, eslint and the markdown lint. The macOS-only branch could not be exercised on Linux.