Repository navigation
Conversation
ServerMessage and Error returned the server's text as is, so a misbehaving server could clear the screen, retitle the window, hide text, overwrite output with a carriage return, or reorder it with a bidi override in any caller that prints the error. newErrorResponse now sanitizes every message, the raw body fallback included (before it is capped): ESC sequences (CSI, OSC and the other string sequences, two-byte escapes) are removed, other C0/C1 controls except newline and tab become a space, and Unicode bidi controls are dropped. Invalid UTF-8 becomes U+FFFD. The same applies to bookshelf transfer errors and to the Location named in a redirect error, and a cookbook checksum mismatch now quotes the manifest's checksum. Fixes #158 Signed-off-by: Tim Smith <tsmith84@proton.me>
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.
ServerMessage()andError()passed server text through unchanged, so a misbehaving server could inject terminal escape sequences, carriage returns or bidi overrides into a caller's output.Every place the library turns server-supplied text into an error string now sanitizes it:
newErrorResponse: each JSONerrorentry, depsolvermessage, top-levelmessage, and the raw body fallback (sanitized before the 512-byte cap, so escapes don't count against it). Messages that sanitize to empty are dropped.transferErrorMessages: S3/bookshelfCode: Messageand the raw body.redirectError: theLocation, parsed or raw.%q-quoted.sanitizeServerTextremoves ESC sequences (CSI; OSC, DCS, SOS, PM, APC ended by BEL or ST, or cut short by a new ESC; two-byte and nF escapes; an unterminated sequence runs to the end), replaces other C0/C1 controls and DEL with a space (newline and tab kept), and drops U+202A-U+202E, U+2066-U+2069, U+200E, U+200F and U+061C. Invalid UTF-8 becomes U+FFFD rather than panicking.Fixes #158
Test plan
go test ./... -race -count=2cd integration && go test -race ./...gofmt -l,go vet,staticcheckclean in both modules