Repository navigation
fix: denyWrite unmasks denyRead when paths overlap (#190 regression) - #195
Merged
Merged
Conversation
…ves dir-allow Two fixes for Linux denyRead precedence. The #190 reorder (denyWrite after denyRead, so .git/hooks ro-binds survive a tmpfs over an ancestor) introduced a regression: when the same file is in both denyRead and denyWrite, denyRead's --ro-bind /dev/null mask now lands before denyWrite's --ro-bind <host> <host>, which undoes the mask. Track masked files and skip those dests when emitting denyWriteArgs — the /dev/null bind already makes them read-only. Separately: a file-level denyRead was silently skipped when allowRead covered its parent directory (startsWith check matched). Narrow the skip to exact matches so denyRead: ['.env'] + allowRead: ['.'] keeps the .env deny. Thanks to kyuz0 (#194) for reporting both.
A file-deny listed before its ancestor dir-deny in the denyRead array was wiped: the /dev/null mask landed first, then the ancestor tmpfs replaced it, then allowRead re-bound the project dir — file readable. Normalize then sort by segment count before the mount loop. Ancestors process first (tmpfs + re-binds), descendant file masks layer on top. User-specified order no longer matters.
ollie-anthropic
approved these changes
Mar 31, 2026
|
Fixes #193 |
1 task
poteat
added a commit
that referenced
this pull request
Jun 12, 2026
#190 buffers denyWrite ro-binds and emits them after the denyRead loop; #195 masks the file-level overlap, but a directory in both deny lists under an allowed write root gets --ro-bind <dir> <dir> stacked on top of its own tmpfs, exposing the real contents read-only. Skip denyWrite binds whose dest a denyRead tmpfs already hides, preserving the #190 exception for dests re-exposed by a re-bound allowed write path. Also the inverse: a denyWrite bind over an ancestor of a denyRead dir re-exposes it from above; re-apply the tmpfs (and its re-binds) on top.
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
Three fixes for Linux denyRead precedence, one of which is a #190 regression.
denyWrite unmasks denyRead (regression from #190). The reorder in #190 emits
denyWritero-binds after thedenyReadloop so.git/hookssurvives a tmpfs over an ancestor. ButdenyWritealso emits--ro-bind <host> <host>for existing files — if the same path is indenyRead, that host-file bind now lands after--ro-bind /dev/null <host>and undoes the mask. We track masked files and skip those dests when emitting the buffereddenyWriteargs; the/dev/nullbind already makes them read-only.File-deny silently dropped by dir-allow. A file-level
denyReadwas skipped whenallowReadcovered its parent directory —startsWith(allowPath + '/')matched,.envstayed readable. Narrowed to exact-match only.Iteration-order dependency. A file-deny listed before its ancestor dir-deny was wiped when the ancestor's tmpfs landed second. We normalize then sort shallow-first so ancestor mounts always land first and descendant file masks layer on top.
Thanks to @kyuz0 (#194) for reporting the first two. We took a simpler approach here that avoids the
maskedDirsfiltering complexity.Links
Test Plan
wrap-with-sandbox.test.ts—/dev/nullmask present + host-file bind absent for overlapping deny lists;.envmask present despite parent inallowRead; tmpfs precedes file mask regardless of user-specified order