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 changesSanitize untrusted values in human Policy CLI reports and diagnostics while preserving raw JSON values. Example: Run policy compare with a filename containing café, BEL, a bidi override, and injected red ANSI styling.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current terminal-output defect using the existing shared encoder; no actionable introduced bugs were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Policy plugin evaluates workspace policy and compares policy files, then renders findings and errors as terminal text or machine-readable JSON. flowchart TD
A[Policy files and CLI arguments] --> B[Policy evaluation and comparison]
B --> C[Reports and command errors]
C --> D[Human output selection]
D --> E[Shared terminal value encoder]
E --> F[Terminal stdout and stderr]
C --> G[Unchanged JSON serialization]
Technical reviewBest possible solution: Land the focused cutover to the existing terminal encoder once the normal exact-head checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source exposes raw values at the reported boundary, and the supplied built-CLI evidence reproduces that behavior on an unchanged baseline; this review executed no target code. Is this the best way to solve the issue? The patch is the smallest complete repair: encode data at existing human-rendering boundaries through the shared owner, retain layout literals, and leave JSON serialization untouched. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a74f408db7fb. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests 0, Docs +3. Total +6 across 3 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 HistoryReview history (1 earlier review cycle)
Reviewed October 28, 2026, 9:39 AM ET / 13:39 UTC (Revision 2). |
Built CLI raw-byte proof at the shared terminal ownerBaseline: current-main Both complete builds succeeded in secretless Linux Docker on Node 24.22.1. The built Human reports were captured from a real PTY using The built CLI ran both conformant and weaker-policy comparisons, twice per case on main and twice per case on candidate: Independent controls:
Owner repair and regressionThe contributor's commits are preserved. Current main was merged because it changed this CLI and supplied the shared The existing unknown-owner regression now includes BEL, C1, bidi and newline characters. It fails main with the raw controls still in stderr, then passes on candidate. The full candidate CLI file reports 38 passed; targeted Oxfmt and Oxlint pass with 0 warnings/errors. The mocked compare duplicate was replaced by the stronger shipped-CLI byte proof above, keeping whole-PR test-line delta 0. Production delta is +3 net lines; documentation records human versus JSON output semantics. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in e2184d8. Thanks @Leon-SK668. Policy CLI reports now escape untrusted values through the shared owner. |
fix(policy): escape untrusted values in policy CLI reports The policy CLI's human-readable reports printed filename-derived values and error text raw, so a crafted name could inject BEL, C1, bidi or ANSI control sequences into the terminal. These reports now go through the shared terminalText owner, as the other CLI reports do since openclaw#186502, and the local writePolicyLine sanitizer is removed. JSON output is unchanged. Evidence: built CLI on Node 24.22.1 with real PTY captures. On main, both the clean and the finding report emitted the injected BEL, C1 NEL, bidi override and ANSI bytes (twice each); with this change they were removed in all four captures and ordinary Unicode was kept. JSON stdout was byte-identical, help kept its 237 intended color sequences, exit codes stayed 0 and 1, and policy files were unchanged. Details: openclaw#186453 (comment). Thanks @Leon-SK668. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: Policy CLI reports and errors can emit terminal controls or bidi overrides embedded in policy filenames, finding text or agent IDs, allowing data to alter a human-readable terminal report.
User Impact
Human-readable
policy check,policy compareandpolicy watchoutput sanitizes untrusted data while preserving report layout, ordinary Unicode and application-owned colors. JSON keeps the original values, policy evaluation and exit codes are unchanged, and policy files are never rewritten by this fix.Why This Change Was Made
Keep Leon-SK668's contributor commit and repair it to use the existing shared
terminalTextowner through the official plugin SDK facade. Tagged templates distinguish report-owned literals from data values before styling. Remove the localwritePolicyLinesanitizer rather than introducing a second output policy or sanitizing a global sink.Current main was integrated because it changed this CLI and provided the shared owner facade. The final diff touches only the CLI, its existing regression and output-mode documentation. Whole-PR production delta +3 net lines, tests 0 net lines. The duplicate mocked compare case is superseded by the real built-CLI byte evidence below; the existing unknown-owner regression now also exercises control and bidi text.
Evidence
Built CLI raw-byte evidence and controls.
Secretless Linux Docker, Node 24.22.1, complete main/candidate builds; explicit task-owned profiles/config/state. The built CLI ran on a real PTY with echo/newline translation disabled, retaining its stdout as binary and analyzing hex/base64. No paid keys or model calls.
e094e4c8…: clean and weaker-policy comparisons each reproduced twice. Human stdout contained filename-derived BEL (07), NEL (c2 85), bidi override (e2 80 ae) and injected SGR (1b 5b 33 31 6d).49753c91…: both cases passed twice with those unsafe data bytes absent; ordinarycaféand emoji text remained. Clean/finding exits remained 0/1 and policy files remained unchanged.The production repair covers report values and error boundaries only. No policy semantics, persistence, permissions, schema, SDK API or machine-output contract changes.
Merge danger: two-way door; reverting restores unsafe human rendering without a migration. Blast radius is human Policy CLI reports/errors. JSON and normal styling have independent controls above.