Skip to content

Harden Container Mount Assertions With A Platform-Aware shellWord (BF-2201) - #1679

Merged
jaywedgeworth22 merged 7 commits into
mainfrom
cursor/bf-2201-shellword-mount-assertions-ac54
Nov 10, 2026
Merged

jaywedgeworth22 merged 7 commits into
mainfrom
cursor/bf-2201-shellword-mount-assertions-ac54

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Aligns the setupCommands mount assertions with the shellWord quoting the commands actually use, per BF-2201, and fixes what the alignment uncovered.

  • The exported shellWord now takes the platform: POSIX keeps main's metachar policy (single quotes, escaped; a backslash or tilde stays bare, as Windows paths have always printed), and win32 gets the double-quote form with doubled inner quotes because cmd.exe ignores single quotes.
  • The two mount assertions pin literal expected strings instead of computing the expectation with shellWord itself.
  • Direct shellWord unit tests cover bare tokens, spaces, quotes, win32 doubling, and the bare backslash and tilde paths.

Verification: pnpm typecheck and vitest server/container-computer.test.ts (106 passing) in an isolated lane. Fixes found by Kody in rounds 1 and 2; every thread answered and resolved. Refs BF-2201 (Done via #945); this hardens the tests it left behind.

Summary

Reworks display quoting for generated container runtime commands so pasted text behaves correctly in POSIX shells and cmd.exe. POSIX words with whitespace or metacharacters are single-quoted, while win32 words are double-quoted with embedded quotes doubled.

Changes

  • Adds a platform parameter to shellWord and threads the target platform through setupCommands command formatting. Leaves words without whitespace or listed metacharacters bare, preserving existing bare rendering of backslashes and tildes in Windows-style paths. Stops quoting --mount type=bind,... workspace strings.

Tests

  • Adds shellWord unit coverage for bare tokens, backslash/tilde handling, POSIX single-quote escaping, and win32 double-quote handling. No test-run results, approvals, or runtime verification are evidenced in the provided diff.

Unresolved risks

  • Automated review reports three medium unverified findings in server/container-computer.ts: brackets/backslash/tilde left unquoted, % and ^ left unquoted on win32, and empty arguments dropped rather than quoted. Impact of these edge cases is unverified.

Summary

Hardens platform-aware shellWord() used for container mount assertions (BF-2201). Empty words can no longer vanish from pasted commands, and POSIX bracket globs plus cmd.exe % / ^ now trigger quoting.

Changes

  • server/container-computer.ts: returns "" on win32 and '' otherwise for empty input. Extends win32 triggers with [, ], ^, % and POSIX triggers with [, ]. Retains existing single-quote vs double-quote escaping per platform.
  • server/container-computer.test.ts: adds coverage for empty words and for bracket, percent, and caret quoting.

Tests

Tests added for the new quoting cases; no run results, deployment, or runtime verification reported.

Open risk

Automated review reports one high finding in server/container-computer.ts:2013: win32 quoting may lose the closing quote on a trailing backslash. Behavior remains unverified.


Summary

Addresses BF-2201 by hardening Windows shell quoting in shellWord. Doubles a trailing backslash run before wrapping a win32 word in double quotes so the closing quote is not escaped under the Windows argv parser.

Changes

  • Updated shellWord in server/container-computer.ts for win32 to duplicate trailing backslashes after escaping embedded quotes. POSIX quoting behavior is unchanged.
  • Added a regression case in server/container-computer.test.ts covering C:\Program Files\ on win32. Run status and runtime verification remain unverified.

Impact

Prevents malformed quoted Windows paths ending with a backslash. No POSIX behavior change is shown by the patch.

Automated code review reported no issues in the reviewed changes.

Export shellWord for setup command display strings and use the allowlist
quoting rule so Windows bind-mount words are single-quoted in previews.
Update container-computer mount expectations to call shellWord instead of
hard-coding unquoted mount specs.

Co-authored-by: Jay Wedgeworth <jaywedgeworth22@users.noreply.github.com>
@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

BF-2201

@kody-ai

This comment has been minimized.

@jaywedgeworth22

Copy link
Copy Markdown
Member Author

Closing as stale: this visibility draft has had no commit in 25 days and its CI is red.  Nothing is deleted: the branch stays on the remote, and the PR can be reopened if the work resumes.  Fleet draft sweep: AFC-679.

Comment thread server/container-computer.test.ts Resolved
Comment thread server/container-computer.ts Resolved
@kody-ai

kody-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Automatic approval held

Kody's assessment:

Changes platform-aware shell quoting for container setup commands with subtle POSIX/cmd escaping rules; compatibility assumptions need human verification despite new unit tests.

@jaywedgeworth22

Copy link
Copy Markdown
Member Author

@kody start-review

@jaywedgeworth22

Copy link
Copy Markdown
Member Author

Reopening: the staleness this close cited is cured on the current head.  The branch was updated onto today's main during the OPS-1054 sweep (merge commit minutes old), the failing checks were from the pre-update head, and the touched-area gates pass locally.  Driving it through the normal path: CI on the fresh head, Kody review, threads resolved, then merge.

Kody: cmd.exe ignores single quotes, so win32 gets the double-quote
form with doubled quotes; POSIX keeps the escaped single-quote form.
Mount assertions now pin literal strings, and direct shellWord unit
tests cover plain, quoted, and win32 paths so quoting regressions
cannot pass by construction.

Refs BF-2201.
The merge had silently replaced main's refined local shellWord — quote
only shell metacharacters, leave a backslash or tilde bare because
Windows paths have always printed as-is — with the branch's wider
Oct 15 rule.  One coherent version now: main's metachar class and
bare-path rule, plus the win32 double-quote form from the review.

Refs BF-2201.
@jaywedgeworth22 jaywedgeworth22 changed the title cursor/bf-2201-shellword-mount-assertions-ac54 Harden Container Mount Assertions With A Platform-Aware shellWord (BF-2201) Nov 10, 2026
@kody-ai

This comment has been minimized.

Comment thread server/container-computer.ts Resolved
Comment thread server/container-computer.ts Resolved
Comment thread server/container-computer.ts Resolved
@jaywedgeworth22
jaywedgeworth22 marked this pull request as ready for review November 10, 2026 03:12
@jaywedgeworth22
jaywedgeworth22 enabled auto-merge (squash) November 10, 2026 03:12
@swu-rob

swu-rob Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Closing as combined into #1737 under Jay's Nov 9 draft burn-down direction. This draft's single commit (BF-2201: align setupCommands mount tests with shellWord quoting) was cherry-picked onto current main and landed as PR #1737, merged at 0a88817. The branch is not deleted.

@swu-rob swu-rob Bot closed this Nov 10, 2026
auto-merge was automatically disabled November 10, 2026 03:13

Pull request was closed

Main landed the BF-2201 alignment independently, which restored the
wide Oct 15 quoting rule and the tautological mount assertions.
Keep one coherent version: main's metachar policy from the earlier
local helper, the win32 double-quote form from review, and the literal
assertions plus the direct unit tests.

Refs BF-2201.
Round-3 review: an empty argument joined as nothing and silently
shifted the pasted command, bracket pairs glob in POSIX shells, and
cmd.exe expands %VAR% inside double quotes and treats ^ as its
escape.  A backslash or tilde still prints bare, per the long
standing Windows-path rule the comment documents.

Refs BF-2201.
@kody-ai

This comment has been minimized.

@jaywedgeworth22
jaywedgeworth22 enabled auto-merge (squash) November 10, 2026 03:26
Comment thread server/container-computer.ts Resolved
…read)

A word ending in a backslash, e.g. C:\Program Files\, closed as \" and the
Windows argv parser treated the closing quote as escaped, merging the next
argument.  The run is now doubled before the quote.  Test added.
@kody-ai

kody-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

Automatic approval held: Changes platform-aware shell quoting for container setup commands with subtle POSIX/cmd escaping rules; compatibility assumptions need human verification despite new unit tests.

@jaywedgeworth22
jaywedgeworth22 merged commit 8d44e3b into main Nov 10, 2026
23 checks passed
@jaywedgeworth22
jaywedgeworth22 deleted the cursor/bf-2201-shellword-mount-assertions-ac54 branch November 10, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants