Documentation
¶
Overview ¶
Package sanitize cleans text before it leaves the console: error messages for a client or the audit log (known secrets in every encoded form, then the product's registered patterns), and any text printed for the human (control and bidi characters escaped, so that client-supplied text cannot drive or spoof the terminal).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var URLUserinfo = regexp.MustCompile(`\b[A-Za-z][A-Za-z0-9+.-]*://([^\s/?#@]+@)`)
URLUserinfo matches the userinfo of a URL ("user:password@" in "amqps://user:password@host"); registered, it drops it. It is not a default: products whose errors carry such URLs register it.
Functions ¶
func Terminal ¶
Terminal escapes s for the human's terminal: C0 and C1 controls and DEL as \xNN; format characters (bidi and directional marks, zero-width characters, the BOM, soft hyphen, tag characters, interlinear annotations), the other default-ignorable code points and variation selectors as \uNNNN or \UNNNNNNNN; so that client-supplied text cannot drive or spoof the terminal, nor hide text from the human. An emoji's variation selector or joiner is escaped too. Newlines and tabs are kept when multiline is set.
Types ¶
type Sanitizer ¶
type Sanitizer struct {
// contains filtered or unexported fields
}
Sanitizer scrubs error text. The zero value is not usable: call New.