fix(opencode): normalise windows permission path patterns through realpath - #47951
Open
CannonRS wants to merge 1 commit into
Open
fix(opencode): normalise windows permission path patterns through realpath#47951CannonRS wants to merge 1 commit into
CannonRS wants to merge 1 commit into
Conversation
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.
Issue for this PR
Fixes #36681
Type of change
What does this PR do?
Permission whitelist entries written as absolute Windows paths were never
compared against the runtime's normalised path form, so a fully-specified
external_directoryallow block still prompted on every external read.Permission.expand()expandes~/…,$HOME/…and keeps the literal string fordrive-letter patterns. The runtime (
external-directory.ts) canonicalises asktargets on Windows via
FSUtil.normalizePathPattern— which resolves symlinksand junctions (e.g.
~/.clauderesolving to~/.codex) and normalisesseparators. A config entry such as
C:\Users\User\.config\opencodethereforenever string-matched the
C:\Users\…\config\*request glob, so the gate fellthrough to the
askdefault: the documented allow block silently did not apply.This change sends the same realpath pass over absolute Windows whitelist
patterns in
expand(), so config patterns and request globs collapse onto thesame canonical prefix. Non-path patterns (
ls,*.env, relative paths) areleft untouched; the drive-letter guard keeps the normalisation scoped to
absolute Windows paths.
How did you verify your code works?
Permission.expandtests cover untouched non-path patterns, tilde/$HOMEexpansion, and (on Windows) drive-prefix + trailing-wildcard survival through
the realpath pass.
fromConfigtilde/$HOMEexpectations to be platform-tolerant(Windows requests the normalised form).
bun typecheckandbun test test/permission/inpackages/opencode:88 pass / 0 fail.
Screenshots / recordings
N/A — not a UI change.
Fork
realpath normalisation in
expand), while fix(opencode): match absolute permission patterns outside the worktree #40149 fixes the tool/request side(external targets sent absolute instead of workspace-relative). The two are
complementary; this PR does not modify tool call sites or
external-directory.ts.Checklist