Documentation
¶
Overview ¶
Package redact masks secrets before anything derived from a request or response reaches logs, the TUI or an error result.
It works two ways (SPEC §5.3, T11):
- by name: auth headers, cookies, and header or query names that look secret (or are configured as secret) have their values replaced;
- by value: every resolved secret is replaced wherever it appears, in its raw, percent-encoded, base64 and JSON-escaped forms. This catches upstream error bodies that echo a key back.
Well-known token formats (GitHub, Stripe, Slack, AWS, JWT, PEM keys, ...) are masked as a backstop even when they were never configured.
Index ¶
- Constants
- type Options
- type Redactor
- func (r *Redactor) Args(args map[string]any) map[string]any
- func (r *Redactor) Bytes(b []byte) []byte
- func (r *Redactor) Header(h http.Header) http.Header
- func (r *Redactor) IsSecretHeader(name string) bool
- func (r *Redactor) String(s string) string
- func (r *Redactor) URL(u *url.URL) string
- func (r *Redactor) Values(args map[string]any) map[string]any
- func (r *Redactor) With(extra ...string) *Redactor
Constants ¶
const Mask = "***"
Mask replaces every redacted value.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor masks secrets. It is immutable after New and safe for concurrent use.
func (*Redactor) Args ¶
Args returns a copy of call arguments for the call log: values under secret-looking names (at any depth) become Mask, and every string has secrets and known token formats masked. args is not changed.
func (*Redactor) Header ¶
Header returns a redacted copy of h. Secret-named headers become Mask, Cookie keeps cookie names but masks their values, and every other value is masked by value and token pattern. h is not modified.
func (*Redactor) IsSecretHeader ¶
IsSecretHeader reports whether values of the header called name must be masked.
func (*Redactor) URL ¶
URL returns a redacted string form of u. Userinfo passwords and the values of secret-named query parameters are masked; parameter order and encoding are kept. The result is then masked by value and token pattern.