protoredact

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NeedsRedaction(m proto.Message) bool

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

func Redacted(m proto.Message) (proto.Message, bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL