Repository navigation
fix(cli): escape terminal controls in plugins enable/disable reports - #185895
huwei-xydt wants to merge 2 commits into
Conversation
Plugin ids and lifecycle warnings printed by openclaw plugins enable/disable are config-derived and could carry ANSI/C0 controls into the operator terminal. Sanitize human report lines with sanitizeTerminalText and extract the policy path into plugins-cli.enable.ts so the grandfathered runtime module does not grow past its line-cap ratchet. Co-Authored-By: Claude Code <[email protected]>
|
🦞👀 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 real behavior proof before merge. What this changesThis PR sanitizes plugin IDs, warnings, and denial reasons in human-readable enable/disable reports. Example: A plugin ID contains alpha, an ANSI color sequence, and a newline followed by forged-row.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: current main still prints these fields without sanitizing them, and this PR provides a focused fix with no introduced correctness defect found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe plugins CLI sends enablement requests to the running Gateway or the existing local mutation owner, then renders returned IDs, warnings, and outcomes to the terminal. flowchart TD
CLI[Plugins enable or disable] --> Adapter[CLI policy adapter]
Adapter --> Gateway[Gateway lifecycle client]
Adapter --> Local[Local mutation owner]
Gateway --> Report[Human report fields]
Local --> Report
Report --> Sanitizer[Terminal sanitizer]
Sanitizer --> Terminal[Operator terminal]
Technical reviewBest possible solution: Retain the existing mutation owners and sanitize untrusted fields only at the human terminal-output boundary. Do we have a high-confidence way to reproduce the issue? Source traces config-derived IDs and lifecycle warnings into unsanitized terminal reports on current main; the contributor reports red/green regression tests, but no target code was executed during this read-only review. Is this the best way to solve the issue? The patch uses the canonical sanitizer at the correct rendering boundary, preserves stored values and mutation semantics, and migrates all references to the extracted command implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a4a8f632da0a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +10, Tests +45. Total +55 across 5 files. Added test files: 0. View PR surface stats
LabelsLabel 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 27, 2026, 8:56 AM ET / 12:56 UTC. |
Keep the plugins-cli.enable.ts extraction and sanitizing reports; drop the duplicate enable path that upstream still holds in plugins-cli.runtime.ts. Co-Authored-By: Claude Code <[email protected]>
…amilies (#186502) fix(cli): route remaining CLI reports through the terminal-text owner After #185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched. This absorbs the per-site fixes from @Leon-SK668 (#184454, #184379, #185374, #186449, #184396, #184788, #184813, #184394), @huwei-xydt (#185895, #185719), @wangmiao0668000666 (#175600, #175181, #175179), @SunnyShu0925 (#184747), @KrasimirKralev (#184597) and @arpe1618 (#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here". Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: #186502 (comment). Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Leon-SK668 <[email protected]> Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Krasimir Kralev <[email protected]> Co-authored-by: arpe1618 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @huwei-xydt. This is now fixed at the root in #186502 (3bcca4f), which routes the remaining CLI reports through the shared |
…amilies (openclaw#186502) fix(cli): route remaining CLI reports through the terminal-text owner After openclaw#185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched. This absorbs the per-site fixes from @Leon-SK668 (openclaw#184454, openclaw#184379, openclaw#185374, openclaw#186449, openclaw#184396, openclaw#184788, openclaw#184813, openclaw#184394), @huwei-xydt (openclaw#185895, openclaw#185719), @wangmiao0668000666 (openclaw#175600, openclaw#175181, openclaw#175179), @SunnyShu0925 (openclaw#184747), @KrasimirKralev (openclaw#184597) and @arpe1618 (openclaw#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here". Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: openclaw#186502 (comment). Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Leon-SK668 <[email protected]> Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Krasimir Kralev <[email protected]> Co-authored-by: arpe1618 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes terminal control sequences and forged output rows when
openclaw plugins enable/openclaw plugins disableprint plugin ids and lifecycle warnings on the Gateway and local-policy paths.User Impact
Human CLI output stays readable when a config-derived plugin id or lifecycle warning contains ESC/BEL/CSI or newline bytes. Success lines, blocked/missing errors, and warnings no longer let untrusted text control the terminal. JSON/config storage paths are unchanged.
Why This Change Was Made
Same
sanitizeTerminalTextpolicy as the mergedsecrets storehuman-output fix (#184141) and the open secrets audit/configure PR (#185719). Enable/disable reports interpolate gateway/local mutation results (result.plugin.id,result.pluginId,warnings, deny reason) into human lines without sanitizing them.Evidence
sanitizeTerminalTextfrompackages/terminal-core/src/safe-text.ts. The policy path lives in new siblingsrc/cli/plugins-cli.enable.ts(extracted fromplugins-cli.runtime.tsso the grandfathered runtime module does not grow past the line-cap ratchet). Callers:src/cli/plugins-cli.tsandsrc/plugins/management-service.policy-imports.test.ts.src/cli/plugins-cli.policy.test.tsplant CSI+newline ids and BEL in gateway warnings / denylist reasons on online enable and local enable+blocked reports.sanitizeTerminalTextfromplugins-cli.enable.ts; both new tests failed with raw ESC in human output (Enabled plugin "alpha\u001b[31m\nforged-row"). Sanitizer restored afterward.-t "escapes terminal controls"→ 2 passed | 14 skipped. Full file → 16/16 passed.plugins-install-warning-output.test.ts3/3;plugins-cli.lazy.test.ts3/3;management-service.policy-imports.test.tsoffline policy path passed.check:line-cap-ratchet --staged --base HEAD→ OK (runtime extracted, no cap growth). oxfmt/oxlint on touched files clean.Notes
fix(cli): escape terminal controls in plugins enable/disable reports.