Skip to content

fix(plugins): sanitize file-derived IDs in authoring reports - #184379

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

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

Conversation

@Leon-SK668

@Leon-SK668 Leon-SK668 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Successful plugins validate and plugins pack reports print the plugin ID read from the project's entry/manifest directly into human terminal output. A normally accepted ID containing control characters can therefore introduce terminal escapes or an extra apparent report line, even though the validation or archive creation succeeds.

Why This Change Was Made

Reuse the existing terminal-text sanitizer at those two human ID interpolations. Both JSON branches return before display formatting, and the packer's raw receipt remains unchanged. The owner is the existing CLI reporting boundary in src/cli/plugins-authoring-command.ts and src/cli/plugins-feature-artifact.ts, reached through plugins-cli.ts.

The current SDK defineToolPlugin/definePluginEntry and normal manifest loader accept these string IDs; normal validation compares exact generated metadata. Tightening that input contract would be a different change. An existing sanitizer already handles the presentation operation, so no new helper, dependency, SDK export, parser, validation rule, or configuration is needed.

This deliberately excludes init/build and explicit output-path confirmations, which echo the operator's arguments. It follows the file-derived-report boundary retained by the maintainer in #176007. Open #173178 fixes JSON5 manifest parsing in the adjacent authoring module and does not implement this output repair.

User Impact

Human validation and pack reports display the ID as readable terminal text, retaining ordinary Unicode while escaping CR/LF/TAB and removing terminal sequences. JSON plugin identity, exact project metadata, archive contents, digest, activation receipt, and output path remain unchanged. No plugin is installed or activated by this change; no permissions, defaults, protocol, storage, or migration behavior changes.

Evidence

Actual compiled-CLI RED: 18d2633de8abd677ae1852b48950701bce8ff302. Exact candidate GREEN: 7e9b0c5af4e4e591877f8b43a9ea3ba1265321ad, based on main f0d422a7cb485eb19ff9671aa3a588cb4cf3a46a. The authoring entry, metadata generator, validation, packer, SDK definition, loader, and package-entry admission owners are identical between the executed baseline and parent. A fresh check against main f5eb9570aac03eccd09bf38d8a155d4039fc768f finds those owners and the five publication contracts unchanged; native merge-tree verification is clean.

The same frozen driver creates two isolated projects using normal built plugins init, replaces each synthetic entry with an ordinary SDK-authored JavaScript plugin, and runs normal plugins build, validate, validate --json, pack, and pack --json. It supplies each project's own installed compiler from the checkout's existing dependency package, without downloading or changing the OpenClaw installation. Fixture paths are ordinary; the controlled ID exists only in the plugin file, never as a validate/pack argv value.

Representative public commands:

node openclaw.mjs plugins validate --root <synthetic-project>
node openclaw.mjs plugins pack --root <synthetic-project> --out <ordinary-output>.tgz

The two project IDs are plain café-🦀 and a controlled string described here with explicit notation: café<ESC>[31m<LF>forged<TAB>row<CR>🦀, where the bracketed names mean code points U+001B, U+000A, U+0009 and U+000D. All 12 actual CLI invocations on each build exit 0 with empty stderr. On RED, validate/pack human output contains the control sequences and forged line; on GREEN it contains visible escape text on the original report line. Init/build output and the Unicode-only fixture remain unchanged.

Captured GREEN human output, with only the fixture directory redacted; \n, \t, and \r below are visible text:

Plugin café\nforged\trow\r🦀 is valid.
Packed café\nforged\trow\r🦀: <fixture>/metadata-café-🦀.tgz
SHA256: 436f045b741ba72134b3e186cca7ff821ad997d60e077b88a85e2fd30d7ed460
Use plugin_activate_artifact with this path and digest to request activation approval.

Captured GREEN validation JSON parses to valid: true, errors: [] and the original controlled ID. Independent readback compares that parsed ID with the source manifest's exact string, including all four control code points above. This paragraph uses explicit code-point notation because the GitHub body transport rewrites the ESC escape representation; the saved raw subprocess output and receipt hashes remain unchanged.

The real controlled archive is 685 bytes with the digest above. Both human and JSON pack commands produce byte-identical archives; a separate reader extracts the actual package/openclaw.plugin.json and compares it byte-for-byte with the source manifest. Its original controlled ID remains intact. The reader also checks actual package/entry files, archive digests, JSON activation path/digest, and all 24 saved process streams. It issues zero new OpenClaw CLI calls. These are real pack/readback operations, without installation, activation, Gateway, model, external API, or production state.

RED takes 41.453 s and exact-head GREEN 37.520 s. The clean source revision and dist/build-info.json.commit match on both runs. Frozen driver SHA256: 4a245f808345d577a57aef54ccc0698073ddf8ae28b1673b21d3cd7ebba7965a; source/build-guard wrapper: ad01d6e60fb9dd52ec8b6bf07ed73f2fab91d7cdc25f8cbe8e521f9daf830192. RED receipt: 6eb5333f81c3126b7a5bac28202234323b9a5b302a4fce73506f024baef762c6; GREEN receipt: 623336bec0f13df85ea5ef2fab5f0c70792dc77c44645b7e45d234f27acb5b8d; independent GREEN readback: dfcccad79c9274e3b9b4010f0d3374725c66f454fa237c05d7eb4ae6992a84f4.

Validation:

OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/plugins-authoring-command.test.ts --maxWorkers=1
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/plugins-feature-artifact.test.ts --maxWorkers=1
pnpm build sourcePerformance
git diff --check
  • Both new display regressions fail before production changes. Final full authoring suite: 27/27 PASS, 138.30 s wall, including 97.605 s normal worker preparation. Artifact wrapper: all 18 native internal cases PASS, 17.35 s wall. The first cold RED run also hit an existing install test's 120 s timeout; the final single full rerun passes without changing the timeout or test semantics.
  • Source-backed scoped tsgo PASS, 94.70 s; canonical typed-lint JSON PASS, zero diagnostics, four files, 293 rules, 62.90 s wall. Scoped format/diff checks PASS. Exact-head sourcePerformance build PASS, 303.09 s. Local verification time is not a product performance benchmark.
  • Four files: production +4/-2 (two existing sanitizer calls and imports), tests +98/-8. Existing JSON-only validation coverage is consolidated with the Unicode/control cases; the native pack regression retains actual archive and receipt verification. Author simplify/test audit completed; independent review was waived by the user. The contributor identity hook stayed enabled.

Not tested: plugin installation/activation, every authoring error diagnostic, sanitization of argv/output paths, GUI terminal rendering, cross-OS, packaged upgrades, broad suites, or hosted PR CI. This is a bounded successful-report repair, without a claim that all plugin diagnostics or all terminals have been exercised.

Agent Transcript

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

Authorized sanitized agent transcript

Assistant: “另一个终端输出候选已缩小范围,排除了仅回显用户输入、维护者曾不接受的改动。”

@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 plugin IDs in successful validation and pack reports while preserving raw JSON and artifact metadata.

Example: A plugin file declares the ID café<ESC>[31m<LF>forged<TAB>row<CR>🦀.

  • Before: Validation and pack reports emit terminal controls and an apparent extra report line.
  • After: Reports display café\nforged\trow\r🦀 visibly on one line, while JSON and archived metadata retain the original ID.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with shipped-entry proof, meaningful regression coverage, passing exact-head CI, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied exact-head compiled-CLI output exercises both changed report owners with ordinary Unicode and file-derived control characters, showing sanitized human output while JSON IDs, archive metadata, digests, and activation receipts remain intact.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Successful plugin authoring reports can contain terminal escapes or forged lines originating in project files.
Reason: The repair applies an existing safe-rendering contract at the existing CLI owners while preserving plugin identity and machine-readable behavior.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI reporting defect with a minimal production change; no actionable introduced defects were found.

Priority: P2
Reviewed head: 7e9b0c5af4e4e591877f8b43a9ea3ba1265321ad

Before merge

None.

Findings

None.

Agent review details

How this fits together

The plugin authoring CLI reads project metadata, validates or packs the project, and emits either structured JSON or human terminal reports.

flowchart LR
  A[Plugin project files] --> B[Authoring validation]
  B --> C[Validation result or pack receipt]
  C --> D[Raw JSON output]
  C --> E[Terminal text sanitizer]
  E --> F[Human success report]
  B --> G[Unchanged plugin archive]
Loading

Technical review

Best possible solution:

Keep the existing reporting owners and sanitize only the displayed IDs, preserving exact metadata, JSON, archives, and receipts.

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

Current-main source accepts the controlled ID and emits it directly at both report boundaries; supplied compiled-CLI before/after results demonstrate the failure, while this read-only review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete repair for the stated successful-report defect: reuse the canonical sanitizer at both presentation boundaries without tightening plugin identity or changing serialization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2499f2be3e88.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced production hunks add only existing sanitizer imports and calls at the two human ID interpolations; both JSON branches return beforehand. (src/cli/plugins-authoring-command.ts:274, 7e9b0c5af4e4)
  • Current-main defect: Fetched main still interpolates unsanitized IDs in validation and pack success reports, and its two production modules match the PR parent. (src/cli/plugins-feature-artifact.ts:172, 2499f2be3e88)
  • Existing sanitizer contract: The existing sanitizer strips ANSI sequences, escapes CR/LF/TAB, removes remaining control characters, and preserves ordinary Unicode; its independent tests cover those contracts. (packages/terminal-core/src/safe-text.ts:11, 7e9b0c5af4e4)
  • Supplied compiled-CLI proof: The full PR body supplies baseline and exact-head compiled-CLI results for Unicode and controlled IDs through validate, validate --json, pack, and pack --json, including captured sanitized output and archive/JSON readback preserving the raw ID. (7e9b0c5af4e4)
  • Maintainer scope precedent: In fix(models): escape terminal controls in model selection reports #176007 (comment), collaborator obviyus records retaining file-derived report sanitization while removing sanitization from operator-argument echoes; this PR follows that boundary.
  • Feature history: History identifies Peter Steinberger as the recurring authoring and artifact contributor, including the original artifact implementation and JSON reporting work; Leon-SK668 also has prior merged authoring-output work. Following older artifact history encountered an unavailable predecessor object, but the origin blob and current-main blame were readable. (src/cli/plugins-feature-artifact.ts:172, 6a97159ececb)

PR surface

Source +2, Tests +90. Total +92 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 4 2 +2
Tests 2 98 8 +90
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 102 10 +92

Review metrics

Metric Value Why it matters
Production versus test LOC Production +4/-2; tests +98/-8 The production repair reuses the existing sanitizer; regression growth covers both report owners and preservation of Unicode, raw JSON, and packed metadata.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Accepted file-derived IDs can corrupt successful terminal reports, with impact limited to plugin authoring output.
  • 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, 4:29 AM ET / 08:29 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