Documentation
¶
Overview ¶
Package envredact decides which environment values are sensitive and masks them for every read surface. Consumers that need the real value (deploy, reconcile, step-up reveal) read the store directly.
Index ¶
- Constants
- func Classify(key, value string, override *bool) (sensitive bool, reason string)
- func IsPlaceholder(v string) bool
- func IsPublicName(key string) bool
- func Map(env map[string]string, overrides map[string]bool) (map[string]string, map[string]Meta)
- func Merge(submitted, stored map[string]string) (map[string]string, error)
- func Secrets(s string, secrets ...string) string
- func SensitiveName(key string) bool
- func SensitiveValue(key, value string) bool
- func URLForLog(raw string) string
- func URLQuery(raw string, keys map[string]bool, mask string) string
- func URLUserinfo(raw, username string) (string, error)
- type Meta
- type PlaceholderError
Constants ¶
const ( ReasonName = "name" ReasonValue = "value" ReasonOverride = "override" ReasonPublic = "public" )
Reasons a value was classified sensitive or plain.
const Marker = "[redacted]"
Marker replaces a known secret found inside free text.
const Placeholder = "••••••••"
Placeholder stands in for a sensitive value on every read surface. A write that sends it back for an existing key keeps the stored value.
Variables ¶
This section is empty.
Functions ¶
func Classify ¶
Classify reports whether key=value is sensitive and why. override, when non-nil, is the operator's explicit choice and always wins.
func IsPlaceholder ¶
IsPlaceholder reports whether v is the masked placeholder.
func IsPublicName ¶
IsPublicName reports whether key carries a browser-public framework prefix.
func Merge ¶
Merge resolves a submitted env against the stored one: a Placeholder keeps the stored value, and a Placeholder with nothing stored fails.
func SensitiveName ¶
SensitiveName reports whether key's name alone marks it sensitive.
func SensitiveValue ¶
SensitiveValue reports whether value looks like key material on its own.
func URLForLog ¶
URLForLog is URLUserinfo for log lines and error text: it never fails, and an unparseable URL is replaced whole because its parse error would echo it.
func URLQuery ¶
URLQuery replaces the value of every query key in keys (matched case-insensitively, keys lowercase) with mask. A malformed URL is returned as is.
func URLUserinfo ¶
URLUserinfo replaces the userinfo of raw with username, because a bare token username leaks just as a password does. A URL without userinfo is returned unchanged; a malformed one is an error.
Types ¶
type Meta ¶
type Meta struct {
Sensitive bool `json:"sensitive"`
Set bool `json:"set"`
ValueRedacted bool `json:"value_redacted"`
Reason string `json:"reason,omitempty"`
Override *bool `json:"override,omitempty"`
}
Meta describes one variable on a read surface without its value.
type PlaceholderError ¶
type PlaceholderError struct{ Key string }
PlaceholderError names a key that was sent as Placeholder but has no stored value to keep.
func (*PlaceholderError) Error ¶
func (e *PlaceholderError) Error() string