Repository navigation
Conversation
On Windows, path.relative() returns an absolute target when the resolved path sits on a different drive or UNC share, and such a relation cannot start with "..". Every containment check that only looked for ".." therefore admitted a target outside its declared root: Build Result stores, Runtime work directories and CLI result exports. Build ids also admitted ':', letting an id like "d:build" resolve as a drive-relative path on Windows. Reject absolute relations at each check and ':' in Build ids. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
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.
Closes #450
Summary
Windows-only containment escapes — POSIX behavior unchanged:
path.relative()returns an absolute path when the target resolves on a different drive or a UNC share, and an absolute relation can never start with... Containment checks that only testedrelation === ".."/startsWith(".." + sep)therefore admitted targets outside their declared root:containedResultPathandbuildResultDirectoryinpackages/result/src/node/store.ts,buildWorkPathinpackages/runtime-local/src/config.ts, andcontainedPathinpackages/cli/src/result-export.ts. Each now also rejectsisAbsolute(relation)— the checklocation.tsalready does correctly.assertBuildIdinpackages/protocol/src/build-id.tsrejected/,\, NUL and dot-directories but not:, sod:buildwas a legal Build id — whichresolve()treats as drive-relative on Windows, escaping the work/result root.:is now forbidden alongside the other path characters.Behavior relative to main
resolve(root, build)cross-drive (C:\root,D:\x)relative()→D:\x, passes..check, escapes rootd:buildassertBuildIdthrowsRed / green
packages/protocol/test/canonical.test.ts:c:andd:buildadded to the rejecting Build id cases — on main both passedassertBuildId. TheisAbsolute(relation)branches are Windows-only reachable, so the behavioral regression coverage lives there; the POSIX code path is unchanged.Verification
node --import tsx --test packages/protocol/test/canonical.test.ts— pass.pnpm check— clean.path.win32.relativesemantics (returns absolute target, never..-prefixed).Merge Danger
:are now rejected (they were already unusable as single filesystem names on Windows).Checklist
Generated with Devin