fix(server): reject foreign directory hints before instance lookup#34256
fix(server): reject foreign directory hints before instance lookup#34256romanilyin wants to merge 4 commits into
Conversation
|
Merge blocker found during review: the PR validates top-level directory query/header hints before InstanceStore.load, but the v2 ServerApi path still has an equivalent directory-hint bypass. packages/server/src/location.ts reads location[directory] and x-opencode-directory, decodes the header, and calls LocationServiceMap.get(...) without ServerDirectory.parse/native-path rejection. Those routes include location-scoped /api/* endpoints such as packages/protocol/src/groups/fs.ts, so a POSIX server can still accept /api/fs/find?location[directory]=C%3A%5CWork%5CRepo without the intended 400. Please apply the same server-native parsing/rejection to LocationMiddleware or a shared parser and add focused tests for location[directory] plus encoded x-opencode-directory on /api/* routes. Local evidence from a clean worktree: bun install --frozen-lockfile passed, focused server tests passed 49/49, and packages/opencode typecheck passed. Note: this account could not submit a formal request-changes review because GitHub reports it lacks explicit repository access. |
|
Addressed in 255e714. Changes:
Verification:
|
|
Follow-up safe-merge review on current head Validation in an isolated worktree merged into current
Current state: the PR is open/non-draft, checks pass, local merge into latest Residual review notes before a maintainer merges: the original v2 |
|
Thanks for the focused fix. I locally validated the PR's merge result against current I don't think this is merge-ready yet:
Other observed state: PR is open, non-draft, mergeable without content conflicts, but stale by 3 commits from current |
255e714 to
86b4435
Compare
|
Addressed the latest review note in Changes:
Verification:
Current GitHub state after push: the PR is mergeable and |
|
Blocking merge on one remaining cross-platform parser issue found by independent review and reproduced locally. I cannot submit this as a formal request-changes review because GitHub says this account lacks explicit repository access. On the current PR head Local reproduction on the PR merge tree: Required before merge:
Validation already run on the local merge result:
GitHub state is still |
86b4435 to
ee7abd5
Compare
|
Addressed the Windows-profile parser blocker in Changes:
Verification:
Current GitHub state after push: PR is mergeable, branch is current with |
Issue for this PR
Closes #34255
Part of #33107
Related: #30895, #19473
Type of change
What does this PR do?
Validates request directory hints before
InstanceStore.load.Query values are consumed once, encoded SDK headers are decoded once, and Windows drive/UNC paths sent to a POSIX/WSL server return a structured 400 instead of being resolved under the server cwd.
The path logic stays behind one small wrapper. This PR does not migrate SQLite/App state, change session matching, resolve symlink identity, or translate Windows paths to WSL paths.
How did you verify your code works?
/mnt/c/...succeeds on WSL whileC:\...and UNC directory hints return 400.Screenshots / recordings
N/A — server/API change.
Checklist