fix(cli): sanitize hardware-controlled terminal output#453
Open
VailElla wants to merge 1 commit into
Open
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughAdds a shared terminal-field encoder for control characters, applies it across core text formatting and Thunderbolt diagnostics, preserves raw JSON values, and adds ANSI, formatter, encoder, and probe safety tests. ChangesTerminal output safety
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Formatter as TextFormatter
participant Encoder as TerminalFieldEncoder
participant ANSI
participant Terminal
Formatter->>Encoder: encode external terminal field
Encoder-->>Formatter: escaped field
Formatter->>ANSI: wrap formatted text
ANSI-->>Terminal: terminal-safe output
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
\\u{HEX}text--watch,--raw, and--tb-debugoutput boundariesSecurity impact
USB/Thunderbolt descriptors and raw IOKit properties are hardware-controlled. Encoding their control characters before terminal interpolation prevents OSC/title changes, injected ANSI state, and forged output rows while keeping the original values inspectable.
Validation
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swift build --quietxcrun swift test --quiet --filter TextFormatterTests— 21 passedxcrun swift test --quiet --filter ANSITests— 5 passedxcrun swift test --quiet --filter Terminal— 6 passedxcrun swift test --quiet --filter terminalEncodingDoesNotAlterJSON— 1 passedThe full suite was also compared against a clean
origin/mainworktree. Both runs report the same 76 existing corpus issues becauseresearch/customer-probesand severalresearch/dumpsfixtures are absent from this checkout; the candidate run includes all 8 new tests, which pass.Summary by CodeRabbit