Skip to content

fix(plugins): prevent terminal controls in installation reports - #184454

Closed
Leon-SK668 wants to merge 1 commit into
openclaw:mainfrom
Leon-SK668:leon/fix-plugin-install-terminal-output-20261026
Closed

Leon-SK668 wants to merge 1 commit into
openclaw:mainfrom
Leon-SK668:leon/fix-plugin-install-terminal-output-20261026

Conversation

@Leon-SK668

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: successful plugin and hook-pack installation reports print accepted file-derived IDs and destination names as terminal controls, allowing metadata to create a forged report line.

User Impact

Installation progress and completion remain readable single-line reports, preserving ordinary Unicode. The real plugin/hook IDs, copied files, configuration keys, SQLite install records, consent and activation behavior remain unchanged. There are no new settings, permissions, storage formats, protocol changes, migrations or required operator actions.

Why This Change Was Made

Use the existing sanitizeTerminalText helper only when interpolating file-derived fields into human messages: the shared directory-install progress, native manifest/package-name notice, and CLI plugin/hook completion. Keeping this in the existing message producers also covers their shared callers without changing raw install results or typed Gateway activity events.

Filtering the entire CLI logger would damage trusted multiline notices, policy boxes and terminal links, so those messages retain their current formatting. Linked source-path confirmations echo the operator's argument and are deliberately unchanged, following the boundary retained in #176007. Existing terminal-core functionality is sufficient; no new parser, helper, validation rule, dependency or output mode is needed.

This is separate from installed list/inspect (#172873), uninstall (#175600), registry search (#175181), hook toggles (#184303), and authoring validate/pack (#184379). Their changed-file lists and the relevant live diffs were checked; none repairs these installation message producers.

Evidence

Actual compiled-CLI RED: 18d2633de8abd677ae1852b48950701bce8ff302. Exact candidate GREEN: cc96e064cb0d26985878f7857cb66ce4264aa58e, based on main 95dff1e02bc59bc86dd6e75ff93d7ab2714daac9. The three changed producers, hook admission, shared CLI logger and terminal sanitizer are identical between the executed RED baseline and parent. A fresh source check against main c60dc99f3f966a844f999598aa41d04b4276e29a confirms these owners and the publication/testing contracts remain unchanged; a native merge-tree check is clean. This is source-equivalence evidence, not a claim that the later main build was executed.

Two frozen drivers use normal local installation through the actual built CLI, with independent configuration, HOME and state directories. Both source paths are ordinary ASCII. The controlled ID occurs only in real HOOK.md or openclaw.plugin.json, never in argv. The hook fixture has its normal descriptor and empty handler; the native plugin has a real package, manifest and compiled JavaScript entry, no dependencies, explicit consent and --no-enable.

Representative public commands:

node openclaw.mjs plugins install <ordinary-source-hook> --force
node openclaw.mjs plugins install <ordinary-source-plugin> --force --no-enable --accept-capabilities

The ordinary ID is leon-café-🦀. The controlled ID is described with explicit code-point notation: leon-café<ESC>[31m<LF>FORGED<TAB>row<CR>🦀, where ESC/LF/TAB/CR mean U+001B/U+000A/U+0009/U+000D. All four CLI invocations on each build exit 0, signal null, with empty stderr.

Actual installation Unsafe stdout controls, RED → GREEN Forged metadata line, RED → GREEN Raw identity and copied files
Ordinary Unicode hook 0 → 0 absent → absent exact
Controlled hook 6 → 0 present → absent exact
Ordinary Unicode native plugin 0 → 0 absent → absent exact
Controlled native plugin 9 → 0 present → absent exact

The unsafe-control count excludes the CLI's intended structural LF; the separate forged-line assertion checks the metadata's embedded LF. Captured GREEN excerpts below use visible \n, \t and \r text, with only the owned fixture path redacted:

Installing to <fixture>/controls/state/hooks/leon-café\nFORGED\trow\r🦀…
Installed hook pack: leon-café\nFORGED\trow\r🦀
Plugin manifest id "leon-café\nFORGED\trow\r🦀" differs from npm package name "leon-owned-install-proof"; using manifest id as the config key.
Installing to <fixture>/controls/state/extensions/leon-café\nFORGED\trow\r🦀…
Installed plugin: leon-café\nFORGED\trow\r🦀

A separate reader opens the actual source and installed files again, rereads both real config files and SQLite databases for each driver, and compares the complete stored records. Hook config retains the exact raw enabled key and config_machine_state[hooks.internal.installs] record. Native plugin state retains the exact raw plugins.installedIndex.index.installRecords[id], accepted-surface receipt and source/target; the plugin system remains disabled and the registration marker is absent. All source/installed bytes match. The reader makes zero OpenClaw CLI calls and performs no writes. No Gateway, hook handler, model, real channel or external service is invoked.

Both source revisions are clean and match dist/build-info.json.commit. Frozen hook driver SHA256: 4591c4b109929afb637bca0ebf97e5ba7116096339e3d18cc5f3d16855134298; frozen native-plugin driver: 9391ef25cd5d86bff7d1f9b506435aa03a4d56a1437bc356a396940c3e35691e. The same drivers run on both builds. Summed CLI time is 49.245 s for RED and 41.008 s for GREEN (not a product performance benchmark).

Saved actual receipt SHA256
Hook RED e7e6767c528aef658084db0e7ef4eba9c63c887a1e56b83569f0955fb5153735
Hook GREEN 5ece306b6645f6fc0a69159a553deb7c5835703759e326adaef15a37e0ee6b6a
Native plugin RED 7f2f5e9e6a885bae9a1deffb87e65b8469db835380c714334c0dd823626e0482
Native plugin GREEN f093be046e41d62cf497f689394a0feb2d9eb5f9b668203d3cfcd18821be1a5e

Separate existing-artifact reader SHA256: 33b139b8989e4da9422241320b5e705556b22a548c365bff20628a517a94b235; its result e50bcff60260e2a897b8e38d48adc84b045b5361de993bdf2b9c4c3d494b2ab2 passes all eight actual RED/GREEN cases. The hashes identify retained local records; the captured output, control observations and real-state readback above are the inline behavior evidence.

Validation:

OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/plugins-cli.install.test.ts src/cli/plugins-install-warning-output.test.ts src/plugins/install.path.test.ts --maxWorkers=1
node --import ./scripts/tsx.mjs scripts/build-all.mts sourcePerformance
git diff --check
  • Tests-only RED: both new CLI control cases fail; all 53 original cases and the two Unicode controls pass. The real-copy control case also fails both expected message assertions while eight other cases pass. After production edits, 66/66 pass. Final frozen-source run after test placement is 69/69 PASS, 123.05 s wall, including the unchanged original install suite, existing warning cases and actual-copy tests.
  • Source-backed scoped tsgo PASS, 106.99 s; canonical original-source-config typed-lint JSON PASS, zero diagnostics, five files and 293 rules, 282.40 s. These wall times include normal shared build-artifact ownership waits. Format/diff checks PASS. Exact-head sourcePerformance build PASS, 289.07 s.
  • Five files: production +7/-4, tests +103/-3. The net three production lines are the canonical sanitizer imports; all four messages are edited in place. Author simplify/test audit completed; independent review was waived by the user. Company author/committer and the contributor identity hook are verified.
  • Test cost and diagnostics: initial CLI RED 192.24 s wall, including 100.864 s cold compilation; real-copy RED 45.21 s; first GREEN 188.29 s. A real 1000-line lint limit then required moving only the new cases into the existing smaller output suite. A subsequent 151.33 s run exposed a test mock-reader mismatch; only the assertion was corrected to the original emitted-record contract. The final 123.05 s run passes without timeout changes, guard relaxation or retries for flakiness. Existing tests and assertions are retained. New CLI cases take 5.094 s total; the real-copy pair takes 8.068 s/0.110 s, with normal module loading paid by the first case.

Not tested: interactive terminal rendering, Windows/macOS, remote/ClawHub installation, linked paths, plugin activation, every failure/inspection/update diagnostic, packaged upgrades, broad suites or hosted PR CI. In particular, opaque error strings and external subprocess output are separate existing paths; this PR does not claim all installation diagnostics are sanitized. The bare-hook proof retains the existing compatibility scan-incomplete notice unchanged.

Agent Transcript

Implemented with Codex assistance. Actual task-scoped visible excerpt; unrelated turns, raw tool logs, credentials, private paths and reasoning omitted.

Authorized sanitized agent transcript

User: “多个子代理并行处理,提高效率。”

Assistant: “lint 拦下了一个真实问题:新增用例让安装测试文件超过 1000 行上限。子代理正在调整测试放置位置,保留原有覆盖和检查强度;生产修复仍维持原范围。”

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Sanitize file-derived identifiers and destinations in plugin and hook installation messages while preserving raw installation data.

Example: Install a plugin whose manifest ID contains café, an ANSI color escape, and a newline before FORGED.

  • Before: The installation report emits the escape sequence and a separate FORGED line.
  • After: The report removes the escape sequence and displays a literal \n, while retaining the original installed ID.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused existing-owner repair with supplied shipped-CLI RED/GREEN evidence, preserved raw state, meaningful regressions, and passing exact-head CI.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied exact-head compiled-CLI output exercises ordinary local plugin and hook installation with metadata-only control characters, shows escaped single-line reports, and records independent unchanged artifact and state readback; interactive terminal and other-platform behavior are explicitly unclaimed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Installing accepted plugin or hook metadata can execute terminal controls or forge an apparent report line.
Reason: The patch restores the established safe-text presentation contract without rejecting accepted identities or adding product policy.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete terminal-output defect with a small, focused patch; no actionable findings remain, and exact-head CI passes.

Priority: P2
Reviewed head: cc96e064cb0d26985878f7857cb66ce4264aa58e

Before merge

None.

Findings

None.

Agent review details

How this fits together

Plugin and hook installers read package metadata, copy artifacts, and record installation state; their CLI messages now sanitize displayed fields without modifying operation inputs or results.

flowchart LR
  A[Package and hook metadata] --> B[Existing installation owners]
  B --> C[Raw artifacts and installation state]
  B --> D[Human message templates]
  D --> E[Canonical terminal sanitizer]
  E --> F[CLI output]
Loading

Technical review

Best possible solution:

Merge the focused display-boundary repair using the existing sanitizer and unchanged installation owners.

Do we have a high-confidence way to reproduce the issue?

Current source accepts embedded controls in IDs and interpolates them into installation reports; the contributor also supplies compiled-CLI RED/GREEN observations, which were inspected without rerunning target code.

Is this the best way to solve the issue?

This is the smallest complete repair for the stated messages: sanitize displayed substitutions in existing owners, preserving raw identities, trusted formatting, and lifecycle behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 79798ed63e1d.

Provenance checked

  • CLI installation acknowledgements changes intended behavior with a stated reason (c916135: The linked refactor moved private operations into their callers while preserving lifecycle and visible output; it does not establish a requirement to emit metadata controls.)
  • Manifest/package-name notice changes intended behavior with a stated reason (3eb8b3a: The installation-flow split retained the stable facade and runtime behavior; this PR explains why only rendered metadata needs conversion.)
  • Shared directory-install progress changes intended behavior with a stated reason (4caeb20: Current-main blame traces the destination report to the shared directory-install refactor. No linked PR was returned; older-content git log searches encountered unavailable blobs, leaving any earlier rationale unknown.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3eb8b3a adds src/plugins/install-installed-package.ts:110 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3eb8b3a0f838; files: src/plugins/install-installed-package.ts)
  • Vincent Koc: Raw commit f1098ee adds src/infra/install-package-dir.ts:272 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f1098ee89478; files: src/infra/install-package-dir.ts)

PR surface

Source +3, Tests +100. Total +103 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 7 4 +3
Tests 2 103 3 +100
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 110 7 +103

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +7/-4; tests +103/-3 Production growth consists of three sanitizer imports; tests cover distinct CLI acknowledgements and real-copy progress/metadata messages.

Labels

Label changes:

  • add P2: Accepted file metadata can manipulate installation reports, with a bounded repair that leaves installation behavior intact.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Accepted file metadata can manipulate installation reports, with a bounded repair that leaves installation behavior intact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 5:46 AM ET / 09:46 UTC.

obviyus added a commit that referenced this pull request Oct 28, 2026
…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]>
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Leon-SK668. This is now fixed at the root in #186502 (3bcca4f), which routes the remaining CLI reports through the shared terminalText owner from terminal-core. Your commit is kept in that merge and you're credited as co-author, so I'm closing this one as covered. For new output sites, please pass untrusted values through terminalText (or displayPath for paths) rather than opening a PR per command.

@obviyus obviyus closed this Oct 28, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants