Repository navigation
Commit d9c799c
fix(cli)!: the CLI opens a sign-in page only for an http(s) address and never through a shell, and os mcp connect registers only an address that passes one parse (#36769)
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — the published skill's `os mcp connect` row and its
eval state no exit condition, no Windows lookup, no address character
set and no output rule, so nothing they teach changes; `skills/**` is
outside this order's file surface
## 维护者速读
- 用户能看到什么变化:命令行登录只为 http 或 https、且字符规范的登录地址自动打开浏览器;连接 Claude Code
时,只登记并打印通过同一套地址校验的服务地址,地址里带用户名或密码会被拒绝;服务器返回的名字、报错、登录地址和验证码一律以单行可见字符打印;在
Windows 上若找到的是 npm 安装的批处理包装,命令以退出码 1 停下并打印那一行。
-
为什么做:命令行工具启动外部程序一律不经过系统外壳、只交出校验过的地址,打印服务器文字时不让它改动终端显示,属于安全加固,由安全席位派发,维护者已裁定采用"停下并打印"方案并保留自定义地址的路径限制。
- 出错会怎样:最坏是浏览器没有自动打开、某个地址被拒绝登记、某段服务器文字显示成转义形式,或 Windows
上没有自动登记,用户照屏幕提示手动完成即可;整单可直接撤回。
- 要你做什么:无
## What changes
The rules:
- **The CLI opens a sign-in page only for an http(s) address written in
plain URL characters, and never through a shell.** `os login` and `os
cloud login` hand the parsed address to the platform's opener as one
argv element with `shell: false` (`open` on macOS, `xdg-open` elsewhere,
`rundll32.exe url.dll,FileProtocolHandler` by its absolute path on
Windows). An address outside the rule is printed, not opened, with a
line saying so. "Browser opened automatically" is printed only when the
opener was started; an opener that could not be started prints its own
line.
- **Server text prints as one line of printable characters.** Every
string a server supplies that `os mcp connect`, `os login` or `os cloud
login` prints or throws (an environment's name and id, an error text,
the sign-in address, the user code, the account's email and id) goes
through one sanitiser, `utils/terminal-text.ts`: control characters (C0
with CR, LF and TAB, DEL, C1), the Unicode line and paragraph separators
and the bidirectional controls are shown as visible escapes, and the
length is capped. The browser still opens the parsed address unchanged.
`--json` records are unchanged.
- **After the Endpoint, Name and Connect block, `os mcp connect` prints
nothing from the control plane but the block's own name and address.**
The Sign-in and Revoke lines now name "the environment" instead of its
display name.
- **`os mcp connect` registers and prints only an address that passes
one parse, on both paths.** Whether it comes from `--url` or from the
control plane, the address parses as an http(s) URL with no user name or
password, is rebuilt from the parsed origin, holds no control character,
and holds only letters, digits, `-._~:/`, `[` and `]` (an IPv6 host's
brackets, and in a `--url` path prefix). An address from the control
plane must also be a bare host (an optional scheme and port). Anything
else exits 1, with nothing registered and no Connect line printed; each
refusal names the characters accepted and a way on (the console for an
environment; `claude mcp add` by hand for `--url`). The printed Connect
line double-quotes an address holding a bracket, since sh-family shells
read brackets as a pattern; the registered argv is unquoted. The `--url`
path-prefix restriction stays, by the maintainer's word.
- **`os mcp connect` starts `claude` from an argv array with `shell:
false` on every platform.** On Windows it runs the `.exe`/`.com` that
the first matching fully qualified `PATH` entry holds (rooted at a drive
letter, or a UNC share), by its absolute path; the current directory,
relative entries and entries rooted at the current drive are not
searched. A batch-file shim there is not run (ruled option A): exit 1,
the printed `claude mcp add` line, and both remedies.
- **Every program the CLI starts carries no shell beyond four measured
allowances**, each pinned by its statement and its inputs (Acceptance
notes).
**BREAKING (Windows): a batch-file `claude` is no longer run.**
- FROM: on a Windows install whose `claude` is a batch-file shim
(`claude.cmd`, which an npm global install writes), `os mcp connect`
registered the server and exited 0.
- TO: it registers nothing and exits 1, printing the `claude mcp add`
line and saying why.
- The fix: run the printed `claude mcp add …` line yourself, or install
Claude Code's native Windows build and run `os mcp connect` again.
**BREAKING: `os mcp connect` registers and prints only an address that
passes the rule above.**
- FROM: an address outside it was registered and printed as given; a
user name or password in `--url` was dropped without a word.
- TO: it is refused with exit 1; nothing is registered and no Connect
line is printed. Each refusal names the characters accepted and a way
on.
- The fix: for `--url`, pass a base URL in those characters with no user
name or password, or run `claude mcp add --transport http NAME URL`
yourself with the server's MCP address; for an environment, check its
address in the ObjectOS Cloud console.
ADR-0087 disposition (stated in the changeset's marker): not-required,
`no-migration-prescription` — no schema key, accepted value, export or
stored row moves; there is nothing for a migration to rewrite and no
tombstone.
Changeset: `@objectstack/cli` patch, carrying the `!` summary, both
declaration lines, the marker and both BREAKING blocks. The CLI
reference (`content/docs/deployment/cli.mdx`, `os login`, `os cloud
login`, `os mcp connect`) states the same rules.
## Tests
Every case title states its rule or a number; sample inputs live in the
data, never in a name.
-
`packages/cli/test/server-text-reaches-the-terminal-as-one-line.test.ts`
(new):
- `terminalText`, 5 cases: every C0, DEL and C1 code point, the
separators and the bidirectional controls come out as visible escapes;
an escape sequence loses its introducer; printable text, other scripts
and emoji are unchanged and a second pass changes nothing; the cap
counts its ellipsis.
- A TypeScript-AST source pin over the six files those flows print from.
Every argument of a print site (the `print*` helpers, `console.*`,
`process.stdout|stderr.write`, `this.log|warn|error`), every `new
Error(…)` message and every `message:` property must be made of
literals, `terminalText(…)`, a declared text function whose own returns
are held to the same rule, a `const` so made, or one of four declared
line-safe expressions (the validated name and address, the line built
from them, and the install-target refusal whose `message:` templates the
pin also holds). Findings must be empty; every flow file has print sites
and the total holds a floor of 100 (111 measured); a roster entry
nothing uses reds. Detector battery: 19 loud cases (a floor per sink
kind) and 14 quiet ones. The walk reads six files: the file ran in 93
ms.
- `packages/cli/test/mcp-connect.test.ts` — on the registering and the
`--print` path, a display name holding control characters leaves the
Endpoint, Name and Connect lines byte-identical to a plain run, adds no
line, leaves exactly one line starting `Connect`, and nothing after the
block names the environment; environment ids, names and the control
plane's error text in a refusal each stay on their line; the bracket
quoting; the `--url` user name and password refusal on both paths; the
way on in both refusals; the control-plane address refusals, numbered 1
to 16; an address with `_` and `~` registers.
-
`packages/cli/test/sign-in-page-opens-http-only-without-a-shell.test.ts`
— both device flows: the printed sign-in address and user code carry no
control byte and add no line, and the browser opens the parsed address
unchanged; the server's error text reaches the thrown error as one line;
the refused-address cases, numbered; a UNC share entry is searched, both
spellings.
- `packages/cli/test/cli-launches-without-a-shell.pin.test.ts` — the
shell-program rule reads either side of `||`, `??` and `?:`; a
`createRequire(…)` result, held or called inline, counts as `require`.
Battery now 40 loud cases (11 / 11 / 8 / 10 per rule, each held to that
floor) and 20 quiet. The header lists what the pin still cannot see.
Measured: the file ran in under 1 s, its walk inside `beforeAll`.
## Acceptance notes
- **Allow-listed in the source pin, measured, not changed here.** The
rule names three text classes an allowed command line may carry: text
the CLI wrote; text held to a fixed character set or a closed set of
values; the invoking user's own argument to the same command.
`commands/doctor.ts` `probeTool` (CLI-written constant probes; every
caller passes a literal, pinned); `commands/dev.ts` `pnpm [--filter
PACKAGE --fail-if-no-match] dev` (the invoking user's own argument,
chosen over a character set because pnpm owns the filter grammar);
`commands/init.ts` `PM install` (closed set); `utils/skills-catalog.ts`
`npm pack` on Windows (exact-version charset and a quoted CLI-created
directory).
- `describeEnvironment` is shared, so `os deploy`'s and `os package
publish --install`'s environment lines print the control plane's name
and id as one line too.
- Not measured on a Windows host: the opener's argv and the client
lookup are pinned with a mocked file probe and a mocked runner. A `PATH`
entry that is a link rather than a regular file is not measured.
- The `--url` narrowing also refuses a base URL whose path prefix holds
a percent-encoded or punctuation character; such a server has no
spelling under the rule, and the refusal names registering it with
`claude mcp add` by hand.
## Verification
<details><summary>Reverse verification (fix committed first; each
mutation through an anchor that must hit, the named files run, the
restore proven blob == HEAD and an empty git diff HEAD)</summary>
19 mutation runs, 16 distinct ablations, each red and then restored:
- One-line rule: the environment name unsanitised in the shared
describer: 3 red. The user code unsanitised (cloud flow): 2 red
(behaviour and source pin). The sign-in address unsanitised (`os
login`): 2 red. The server's error text unsanitised in the thrown error:
2 red. An account email unsanitised (`os cloud login`): 1 red (source
pin). The sanitiser disabled: 10 red.
- Source-pin detector: text-function returns unchecked: 2 red.
- Address rule: bracket quoting removed: 2 red. `--url` user name and
password refusal removed: 2 red. The control-plane refusal's way on
removed: 16 red. The `--url` refusal's way on removed: 1 red.
- Windows lookup: UNC entries not searched: 1 red.
- No-shell pin: a shell program behind `||`/`??` unread, in `?:` unread,
an inline `createRequire` load unread, a held `createRequire` result
unread: 1 red each.
- Three first attempts were refused by the mutation tool before any test
ran (each replacement already occurred in the file); each was re-run
with a disjoint replacement.
- After all of them: 0 changed paths, empty `git diff HEAD`.
</details>
<details><summary>Local runs (final head bde1e1b unless a line names
another)</summary>
- `pnpm --filter @objectstack/cli typecheck` (tsc +
`check:test-typecheck`) → `VERDICT command-exit 0`,
`check:test-typecheck: OK`.
- The four files above → `Test Files 4 passed (4)` (mcp-connect 42,
sign-in 41, the new pin 10, the no-shell pin 5).
- CLI `unit` tier (`vitest run --project unit`) → `Test Files 442 passed
(442) · Tests 6316 passed (6316)`. The `integration` tier is declared to
CI.
- `eslint --no-inline-config` over the ten touched TypeScript files →
exit 0; `check-nul-bytes` → OK; control-byte scan over every touched
file → no match; `check-platform-checklist --changed-from origin/main` →
exit 0.
- Derived gate list (`dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`), 102 families, each exit captured before
any pipe: 102 × exit 0. `--ran` reconciliation: `102 derived, 102 run, 0
NOT-MEASURED, 0 UNRUN`. The derivation warned that the tree is 7 commits
behind `origin/main`; `main` was not merged, as no conflict or
main-caused red asks for it.
- Dogfood battery (the title carries `!`): `pnpm --filter
'@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood
test` under the lock → `VERDICT command-exit 0` · `Test Files 487 passed
| 3 skipped (490)` · `Tests 4125 passed | 68 skipped (4193)`, no
failure.
- Not measured: a Windows host.
</details>
Read first: `packages/cli/src/utils/terminal-text.ts`,
`packages/cli/test/server-text-reaches-the-terminal-as-one-line.test.ts`
(the sinks and the roster), `packages/cli/src/commands/mcp/connect.ts`
(`run`, `mcpUrlFromBase`, `claudeMcpAddLine`).
Two-minute check: `pnpm --filter @objectstack/cli exec vitest run
--maxWorkers=2 test/server-text-reaches-the-terminal-as-one-line.test.ts
test/mcp-connect.test.ts
test/sign-in-page-opens-http-only-without-a-shell.test.ts
test/cli-launches-without-a-shell.pin.test.ts` → `Test Files 4 passed
(4) · Tests 98 passed (98)`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ASNY8XNef4ywkQio6S9ju4)_
<!-- signed: security#1 · os-mickey · session_01ASNY8XNef4ywkQio6S9ju4
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 47ed85d commit d9c799c
13 files changed
Lines changed: 2008 additions & 91 deletions
File tree
- .changeset
- content/docs/deployment
- packages/cli
- src
- commands
- cloud
- mcp
- utils
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3484 | 3484 | | |
3485 | 3485 | | |
3486 | 3486 | | |
3487 | | - | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
3488 | 3494 | | |
3489 | 3495 | | |
3490 | 3496 | | |
| |||
3583 | 3589 | | |
3584 | 3590 | | |
3585 | 3591 | | |
3586 | | - | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
3587 | 3596 | | |
3588 | 3597 | | |
3589 | 3598 | | |
| |||
3852 | 3861 | | |
3853 | 3862 | | |
3854 | 3863 | | |
3855 | | - | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
| 3868 | + | |
| 3869 | + | |
| 3870 | + | |
| 3871 | + | |
| 3872 | + | |
| 3873 | + | |
| 3874 | + | |
| 3875 | + | |
| 3876 | + | |
| 3877 | + | |
| 3878 | + | |
3856 | 3879 | | |
3857 | 3880 | | |
3858 | 3881 | | |
3859 | 3882 | | |
3860 | 3883 | | |
3861 | | - | |
3862 | | - | |
3863 | | - | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
| 3887 | + | |
| 3888 | + | |
| 3889 | + | |
| 3890 | + | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
3864 | 3894 | | |
3865 | 3895 | | |
3866 | 3896 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
212 | | - | |
| 213 | + | |
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
| |||
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | | - | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| |||
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | | - | |
265 | | - | |
| 265 | + | |
| 266 | + | |
266 | 267 | | |
267 | 268 | | |
268 | 269 | | |
| |||
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
280 | | - | |
| 281 | + | |
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
| |||
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 231 | | |
240 | 232 | | |
241 | 233 | | |
| |||
288 | 280 | | |
289 | 281 | | |
290 | 282 | | |
291 | | - | |
| 283 | + | |
292 | 284 | | |
293 | 285 | | |
294 | 286 | | |
| |||
302 | 294 | | |
303 | 295 | | |
304 | 296 | | |
305 | | - | |
| 297 | + | |
306 | 298 | | |
307 | 299 | | |
308 | 300 | | |
| |||
370 | 362 | | |
371 | 363 | | |
372 | 364 | | |
373 | | - | |
| 365 | + | |
374 | 366 | | |
375 | 367 | | |
376 | 368 | | |
| |||
405 | 397 | | |
406 | 398 | | |
407 | 399 | | |
408 | | - | |
409 | | - | |
| 400 | + | |
| 401 | + | |
410 | 402 | | |
411 | 403 | | |
412 | 404 | | |
| |||
429 | 421 | | |
430 | 422 | | |
431 | 423 | | |
432 | | - | |
| 424 | + | |
433 | 425 | | |
434 | 426 | | |
435 | 427 | | |
| |||
455 | 447 | | |
456 | 448 | | |
457 | 449 | | |
458 | | - | |
| 450 | + | |
459 | 451 | | |
460 | | - | |
| 452 | + | |
461 | 453 | | |
462 | 454 | | |
463 | 455 | | |
464 | 456 | | |
465 | | - | |
466 | | - | |
| 457 | + | |
467 | 458 | | |
468 | 459 | | |
469 | 460 | | |
| |||
521 | 512 | | |
522 | 513 | | |
523 | 514 | | |
524 | | - | |
525 | | - | |
| 515 | + | |
| 516 | + | |
526 | 517 | | |
527 | 518 | | |
528 | 519 | | |
| |||
543 | 534 | | |
544 | 535 | | |
545 | 536 | | |
546 | | - | |
| 537 | + | |
547 | 538 | | |
548 | 539 | | |
549 | 540 | | |
| |||
0 commit comments