[WRONG BRANCH] fix(cli): neutralize terminal control characters in usage report - #330
[WRONG BRANCH] fix(cli): neutralize terminal control characters in usage report#330luvs01 wants to merge 1 commit into
Conversation
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe usage report now escapes ASCII and extended control characters before rendering headers, cells, scope descriptions, and no-match filter descriptions. Tests verify that escape and bell characters appear as inert escaped text. ChangesUsage report sanitization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change makes provider and model identifiers inert in human usage reports by escaping terminal control characters, with focused tests and validation checks passing; no actionable merge-blocking risk remains beyond normal review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Motivation
ocx usagerenderer printedproviderandmodelidentifiers verbatim, allowing logged control/OSC sequences to reach operator terminals and manipulate output (OSC 52, BEL, ESC, etc.).Description
terminalTextsanitizer that replaces C0, DEL and C1 control characters with visible escape text (\x../\u....) to prevent terminal interpretation.\n- Apply the sanitizer to table headers/rows intable()and to scope/No usage recordedmessages so attacker-controlledprovider/modelvalues are inert before printing.\n- UpdateformatUsageReportusage so all human-facing label cells are neutralized.\n- Add a focused regression test that injects ESC/OSC/BEL/newline intoprovider/modelvalues and asserts the output contains escaped literals rather than control bytes.Testing
bunx bun@1.4.0 test tests/cli-usage-report.test.ts— passed (13 tests).\n-bun run typecheck— passed.\n-bun run privacy:scan— passed.\n-git diff --check— passed.\n- Note: a repository-widebun testrun with the preinstalled Bun (older system binary) failed due to a runtime mismatch (zstdDecompressSyncexport), so a focused run using the repository-declared Bun (bunx bun@1.4.0) was used to validate the change successfully.Codex Task
Summary by CodeRabbit