Documentation
¶
Overview ¶
Package protoredact masks the fields of a protobuf message that are marked [debug_redact = true] in the schema, so the message can be logged without exposing the secrets it carries. The label is set next to the field in the .proto file; this package is the reader for it, since the Go protobuf runtime does not act on the option itself.
Index ¶
Constants ¶
const Placeholder = "[REDACTED]"
Placeholder replaces the value of a singular string field marked debug_redact. Names and structure are kept so a log line still shows which fields were set.
Variables ¶
This section is empty.
Functions ¶
func NeedsRedaction ¶ added in v0.4.0
NeedsRedaction reports whether logging m as it is would expose a debug_redact field: m is a valid message, its type can reach such a field, and at least one is populated. A nil message, a type that cannot reach a labeled field (Actor, ListActorsResponse, Worker, ...) and a message whose labeled fields are all unset (an ActorTemplate with no env) all answer false. The type check is memoized; the populated walk stops at the first hit and visits only sub-messages whose type can reach a labeled field.
func Redacted ¶ added in v0.4.0
Redacted returns m with every debug_redact field masked, without modifying m, and whether anything was masked. When NeedsRedaction(m) is false it returns m itself and false: there is nothing to mask, so nothing to copy, and callers must treat the result as read-only. Otherwise it returns a masked deep copy and true. Use the bool rather than comparing the result with m: comparing two proto.Message values panics when the dynamic type is not comparable.
Types ¶
This section is empty.