Skip to content

fix(oc-path): sanitize file-derived human inspection reports - #184394

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

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

Conversation

@Leon-SK668

Copy link
Copy Markdown
Contributor

What Problem This Solves

path resolve --human and path find --human can copy C1 terminal-control characters from a JSONC key/value into an inspection summary. JSON quoting already escapes C0 characters, but it leaves C1 characters intact. A successful inspection should display readable text while preserving the underlying file and address identities.

Why This Change Was Made

Reuse the existing public SDK sanitizeTerminalText at the shared human leaf formatter and at find's concrete-path display. Quote leaf values first to preserve the existing visible quoting. No new sanitizer, dependency, parser rule, configuration, or API is needed. registerPathCli owns these summaries; the existing find/resolve adapters and JSONC scanner supply the original data.

The actual installed jsonc-parser scanner accepts these C1 characters in ordinary JSON strings. Rejecting them or rewriting canonical paths would change the data contract. Explicit emit --human, dry-run source and diff output are byte-oriented artifacts, so their existing behavior is retained. This follows the accepted file-derived reporting boundary, rather than changing operator-argument echoes.

All-state symptom, symbol and owner-path searches found no equivalent implementation. Open #172164 covers wildcard array tests and #180918 covers frontmatter comments; their overlap with the old test module does not implement this rendering fix. All original 70 tests remain unchanged.

User Impact

Human inspection keeps ordinary Unicode readable and strips control sequences from file-derived summaries. Structured JSON retains the exact original key/value/address. Explicit raw exports and source files retain their original bytes. There are no permission, configuration, default, storage, protocol, migration or dependency changes.

Evidence

Compiled-CLI RED: clean 18d2633de8abd677ae1852b48950701bce8ff302; GREEN: clean e230c34d3e215152d0d05ed418bcb6cf33ccd7ba, parent main f0d422a7cb485eb19ff9671aa3a588cb4cf3a46a. The CLI/find/resolve/SDK sanitizer owners match between executed RED and parent. Fresh main 95dff1e02bc59bc86dd6e75ff93d7ab2714daac9 retains these owners and the publication contracts; native merge-tree verification is clean. Each run checks dist/build-info.json.commit == HEAD.

The same frozen recorder uses ordinary synthetic JSONC files and the real built CLI/plugin registration in fresh isolated HOME/config/state. Its four actual commands are:

node dist/entry.js path find 'oc://report.jsonc/*' --file <fixture>/report.jsonc --human
node dist/entry.js path find 'oc://report.jsonc/*' --file <fixture>/report.jsonc --json
node dist/entry.js path find 'oc://positive.jsonc/*' --file <fixture>/positive.jsonc --human
node dist/entry.js path emit <fixture>/report.jsonc --human

The controlled key is café followed by CSI/OSC/ST sequences (code points U+009B, U+009D and U+009C); the value starts 中文🍵 and contains the same kinds of controls. Both are accepted as normal file contents. All four commands exit 0 with empty stderr on both builds. RED human find contains six C1 characters; GREEN contains zero and produces this captured stdout:

1 match for oc://report.jsonc/*:
  oc://report.jsonc/café  →  leaf @ L1: "中文🍵" (string)

The Unicode-only positive remains identical. JSON parses to the original controlled path/value on both builds, and explicit emit --human remains byte-identical to the controlled input, including all six C1 characters. A separate reader reopens the actual two source files/config, checks their hashes, reparses JSON and all eight captured stdout/stderr streams, and checks exact human/raw output. It invokes zero new OpenClaw commands. There is no internal result injection, Gateway, model, external API or production state.

RED takes 19.87 s; GREEN takes 20.12 s. Recorder SHA256 9083f2b67433dee304e7a3088dc40d36e1e6a919d0592d331639159d1baf4d8c; independent reader 042849e3bda7a7802ff5da16a439fcb7e688a73f8a15f9a0f3ba7367b45023f0. RED receipt d2661f4f50144326bbdaa4763e3e570c62eb0b9152c6fc37005fd3874ba97eef; GREEN receipt ca98087a4ca95f24b524df6c1a1e07676bf99f90b6f95c797d3366871e533d51. Raw JSON stdout hashes match across runs: d7e27e2816aa937bb3bbaa3daadb741d68681e1ea9edd956b868bc295a218e73.

Validation:

OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs extensions/oc-path/src/cli.test.ts extensions/oc-path/src/cli-human.test.ts --maxWorkers=1
pnpm build sourcePerformance
git diff --check
  • Tests-only RED: both registered resolve/find regressions fail, explicit raw emit passes; wall 137.99 s, including cold worker transformation. Final combined GREEN: 73/73 PASS, wall 32.60 s; new bodies 125/20/8 ms. The original 70 tests are byte-for-byte unchanged. New tests live in a focused module to retain the canonical 1000-line limit.
  • Source-backed tsgo PASS, 20.02 s; canonical typed lint with original tsconfig.extensions.json, full preparation and JSON diagnostics: zero diagnostics, two files, 293 rules, 87.05 s wall. Format/diff PASS. Exact-commit sourcePerformance build PASS, 298.58 s. These are local verification timings, not a runtime benchmark.
  • Two files: production +6/-2 (net +4: import, two display conversions and boundary comment); new tests +61. Full author simplify/test audit has no remaining accepted finding. Independent review was waived by the user; the normal contributor identity hook remained enabled.

Not tested: actual interactive TTY/screen/title effects, browser UI, cross-OS, packaged upgrades, every format, native resolve as a separate subprocess, broad suites or hosted PR CI. Registered resolve tests exercise the shared formatter. Xterm.js and classic XTerm differ in UTF-8 C1 handling; this proves the actual stdout boundary and makes no universal terminal-execution claim.

Agent Transcript

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

Authorized sanitized agent transcript

Assistant: “终端报告两条修复的构建已通过;oc-path 原生验证也通过,JSON 和原始导出字节保持不变,memory 的真实索引/搜索验证正在完成。”

@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.

@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 leaf values and concrete paths in human-readable OC Path inspection reports.

Example: Run path find on report.jsonc containing a café key and 中文🍵 value with U+009B, U+009D, and U+009C sequences.

  • Before: The human report includes six C1 control characters from the file.
  • After: The report displays café and "中文🍵" without those sequences, while JSON output and source bytes retain the original data.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful fix with shipped CLI evidence, meaningful boundary tests, and no identified correctness or security regression.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied terminal output exercises the exact-head built CLI and plugin registration in isolated state: find human output removes the controlled key/value sequences, the Unicode control stays identical, and JSON plus explicit emit preserve original data; registered resolve coverage exercises the shared formatter.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Inspecting ordinary file contents can copy terminal-control sequences into successful human reports.
Reason: The patch restores the existing terminal-text boundary without altering file data, machine-readable identities, or byte-oriented exports.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current, source-verified rendering bug with a focused change and supplied CLI proof; no actionable defect was found.

Priority: P2
Reviewed head: e230c34d3e215152d0d05ed418bcb6cf33ccd7ba

Before merge

None.

Findings

None.

Agent review details

How this fits together

The bundled OC Path plugin parses workspace files, resolves addresses, and renders CLI inspection results as human text or structured JSON.

flowchart LR
  A[Workspace file] --> B[Format parser]
  B --> C[Path resolution and find]
  C --> D[Human report sanitizer]
  C --> E[Structured JSON output]
  D --> F[Terminal stdout]
Loading

Technical review

Best possible solution:

Merge the focused display-boundary fix while preserving canonical addresses, structured output, and raw export bytes.

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

Current-main rendering exposes the reported path: JSONC string values reach JSON.stringify and concrete paths reach stdout without C1 sanitization; supplied CLI evidence demonstrates the before/after result, but this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete fix: reuse the canonical sanitizer in the existing human renderer, with no parser changes, competing owner, or new configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 977d7287c010.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e3b33a2 adds extensions/oc-path/src/cli.ts:180 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e3b33a26cdb1; files: extensions/oc-path/src/cli.ts)

PR surface

Source +4, Tests +61. Total +65 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 1 61 0 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 67 2 +65

Labels

Label changes:

No label changes.

Label justifications:

  • P2: File-derived control sequences affect an optional CLI inspection surface; the fix has a narrow display-only scope.
  • 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:42 AM ET / 08:42 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

extensions: oc-path 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