Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR sanitizes human-readable routing-binding reports while preserving raw JSON values and stored configuration. Example: A stored Telegram account ID contains café followed by ESC[2J, BEL, and a newline before FORGED.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current terminal-rendering defect with a focused patch, relevant regression coverage, and supplied CLI evidence; no actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe agents CLI reads configured routing bindings, formats their descriptions, and sends them either to human-readable terminal output or machine-readable JSON. flowchart LR
A[Stored routing bindings] --> B[Agents binding commands]
B --> C[Raw binding descriptions]
C --> D[Terminal sanitizer]
D --> E[Human report]
C --> F[JSON output]
Technical reviewBest possible solution: Apply the existing sanitizer only at the binding commands’ terminal-output boundaries and preserve raw routing and JSON values. Do we have a high-confidence way to reproduce the issue? Current-main schema and output code establish the path from control-bearing stored match fields to raw terminal output, supported by the contributor’s pinned base/head CLI results; this review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair for the stated command boundary: it reuses the canonical sanitizer without changing the shared raw formatter or introducing another rendering owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ff26768c39d6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2, Tests +49. Total +51 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 18, 2026, 9:53 PM ET / October 19, 2026, 01:53 UTC. |
fix(cli): escape terminal controls in untrusted values through one owner CLI human-readable output printed user-controlled values such as config paths, names, directories, binding descriptions, plugin metadata and dead-letter scopes without neutralizing terminal control sequences, so a crafted value could inject ANSI, OSC 8 or C1 sequences into the terminal. Earlier fixes wrapped one call site at a time. A single owner now does this: `terminalText` in terminal-core's safe-text escapes interpolated values before styling, and the display-only `displayPath` delegates to it. Raw path shortening, JSON output and the trusted styling of `renderTable` are unchanged, and the per-site wrapping is replaced. This absorbs #184685, #184666, #184324, #184303, #176763, #176773 and #172873 by @Alix-007 and #184861 by @qingminglong, whose original commits are kept, and moves the earlier merged per-site fixes onto the same owner. Evidence: built CLI in a secretless container, with ESC/CSI, OSC 8 and C1 sequences injected into values for eleven commands across eight families. Main printed the raw sequences; this change printed them neutralized, normal colored output and JSON values were unchanged, and dead-letter errors keep their stderr and JSON contracts. Raw-byte captures: #185927 (comment). Production +81. Co-authored-by: Alix-007 <[email protected]> Co-authored-by: qingminlong <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
@shakkernerd: #185927 (2d2b465) landed a root-cause fix that routes the covered CLI report values through one Rechecked against current main |
fix(cli): escape terminal controls in untrusted values through one owner CLI human-readable output printed user-controlled values such as config paths, names, directories, binding descriptions, plugin metadata and dead-letter scopes without neutralizing terminal control sequences, so a crafted value could inject ANSI, OSC 8 or C1 sequences into the terminal. Earlier fixes wrapped one call site at a time. A single owner now does this: `terminalText` in terminal-core's safe-text escapes interpolated values before styling, and the display-only `displayPath` delegates to it. Raw path shortening, JSON output and the trusted styling of `renderTable` are unchanged, and the per-site wrapping is replaced. This absorbs openclaw#184685, openclaw#184666, openclaw#184324, openclaw#184303, openclaw#176763, openclaw#176773 and openclaw#172873 by @Alix-007 and openclaw#184861 by @qingminglong, whose original commits are kept, and moves the earlier merged per-site fixes onto the same owner. Evidence: built CLI in a secretless container, with ESC/CSI, OSC 8 and C1 sequences injected into values for eleven commands across eight families. Main printed the raw sequences; this change printed them neutralized, normal colored output and JSON values were unchanged, and dead-letter errors keep their stderr and JSON contracts. Raw-byte captures: openclaw#185927 (comment). Production +81. Co-authored-by: Alix-007 <[email protected]> Co-authored-by: qingminlong <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @obviyus for the detailed follow-up on the routing reports and the shared fix. Much appreciated. |
|
Hi @shakkernerd, could you take a look at the final disposition here when you have a chance? It's been open for over a week; #185927 already includes the fix with co-author credit. Thanks! |
|
Closing this as absorbed by the merged #185927, with contributor credit retained. Thanks @obviyus for integrating the fix, and @shakkernerd for taking a look! |
What Problem This Solves
Fixes: routing binding reports can clear terminal output or insert extra report lines when configured match fields contain control characters.
User Impact
User impact: operators can read routing reports safely without changing routing keys, stored configuration, JSON output, or ordinary Unicode text.
Why This Change Was Made
Apply the existing terminal sanitizer at the binding command's human-readable output boundaries, including mutation summaries and conflicts. Keep the shared binding description formatter raw for JSON consumers. No config/default, protocol/schema, permission/security-policy, dependency, compatibility, or migration changes.
Evidence
Normal-built CLI, Node 26.1.0 on Linux, isolated HOME/config/state, no external services or production credentials:
e63269c28a22a6eec7c0758d54dc6dbe674e2886(RED run 2026-10-19T01:09:29.616Z).40e10c66f3701718c422c8e2ed929065e8230cc1(GREEN run 2026-10-19T01:30:02.623Z).node <checkout>/openclaw.mjs agents bindings [--agent main|--json]; canonical owner:src/commands/agents.commands.bind.ts.agents bindingsagents bindings --agent mainThe schema-accepted fixture places
café\x1b[2J\x07\nFORGEDin account, peer, guild, team and role strings. HEAD printscafé\nFORGED(a visible backslash+n) in each field, with no injected line. This is a display-hardening claim, not a claim that control-bearing IDs are valid remote service IDs.Controls: 0 unsafe controls and 0 injected lines in two text modes; five visible escaped newlines per mode; raw JSON match fields/description preserved; exact ordinary Unicode report unchanged; config bytes unchanged.
Focused regressions:
OPENCLAW_VITEST_RUNTIME=node pnpm test src/commands/agents.bind.commands.test.ts --maxWorkers=1— 14/14 pass, exit 0; 3.47 s selected shard, 7.68 s including wrapper. Core and canonical commands-test type checks, explicit type-aware lint (including the modified test), format, line-cap ratchet, and independent adversarial review passed. The host's older glibc cannot load tsrs, so type checks used the documentedOPENCLAW_TYPECHECKER=tsgofallback.Generated proof receipt
e63269cand head40e10c6:node proof-bindings.mjs <checkout> <red|green>Reproduce the real CLI proof
Install the pinned dependencies in clean checkouts at the SHAs above, then build normally with
pnpm build qaRuntime(used on BASE) orpnpm build cliStartup(used on HEAD; core CLI only). Save the two files below together outside the checkout. The same collector and scenario run on both versions:Invocation form:
node proof-bindings.mjs <checkout> <red|green>. Only the helper import path is flattened for copying. The collector checks clean Git HEAD against the build stamp and records stdout, stderr, exit status, and readback in its printed temporary receipt directory.proof-bindings.mjs:proof-cli-common.mjs:Scope and limitations
Two files; production/test LOC (added, removed):
Existing-solutions preflight: reused the canonical terminal-core sanitizer; no new abstraction. Sibling coverage: list, bind/unbind description sections and conflict text share this owner; shared raw formatter and JSON bypass preserved; agents list already safe; interactive add wizard outside scope.
Not tested: real channel delivery, rich PTY colors, Windows/macOS terminals, interactive add wizard, full CI suite locally; mutation text/JSON covered by focused unit tests, real CLI proof covers read-only list variants. Fixtures remain in their printed temporary directories for inspection; remove only those generated directories after inspecting them. No production data, existing sessions, channels or service configuration were loaded or changed.