secret

package
v0.98.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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

Index

Constants

View Source
const Redacted = "[REDACTED]"

Variables

This section is empty.

Functions

func Contains

func Contains(value any) bool

func FitsType

func FitsType(source, target reflect.Type) bool

FitsType reports whether every statically known secret field in source has an exactly corresponding secret field in target. Generic interfaces are not a valid destination for a secret.

func FitsValue

func FitsValue(value any, target reflect.Type) bool

FitsValue is the runtime counterpart to FitsType. It checks the actual values of dynamic maps and slices before they enter an action.

func IsEmpty

func IsEmpty(value Value) bool

func IsSecretType

func IsSecretType(t reflect.Type) bool

func IsValue

func IsValue(value any) bool

func Sanitize

func Sanitize(value any) any

Sanitize returns a value safe for observers and event sinks. Secret leaves become the redaction marker; other values are preserved where possible.

func SanitizeBoundary

func SanitizeBoundary(value any, target reflect.Type) (sanitized any, secrets []string)

SanitizeBoundary redacts fields declared as Secret in a schema contract, including plain wire strings observed before request materialization.

func SanitizeError

func SanitizeError(err error, values ...any) error

SanitizeError creates an observer-safe error when the associated payload contains a Secret. It deliberately does not unwrap the original error.

func SanitizeErrorWithSecretValues

func SanitizeErrorWithSecretValues(err error, secrets ...string) error

SanitizeErrorWithSecretValues removes raw wire Secret strings from an error associated with a request before those strings have been wrapped as Values.

func SanitizeWithSecretValues

func SanitizeWithSecretValues(value any, secrets ...string) any

SanitizeWithSecretValues redacts known secret strings from JSON-compatible values. It is used for raw wire payloads before a schema has materialized Secret.Value instances.

func SanitizeWithSources

func SanitizeWithSources(value any, sources ...any) any

SanitizeWithSources redacts Secret leaves and any echoed secret contents in a value before it leaves the execution boundary for an observer or sink.

func TypeContains

func TypeContains(t reflect.Type) bool

func WireType

func WireType(t reflect.Type) reflect.Type

WireType replaces each Secret leaf with its string wire shape for structural JSON checks. Flow values remain Secret.Value and still require FitsType.

func WithValue

func WithValue(value Value, fn func([]byte) error) error

WithValue exposes the secret bytes only for the duration of fn.

func WithoutSecrets

func WithoutSecrets(t reflect.Type) reflect.Type

WithoutSecrets returns a static type containing the public fields that can remain in an inherited payload after Secret-bearing fields are removed.

Types

type Scrubber

type Scrubber struct {
	// contains filtered or unexported fields
}

Scrubber remembers bounded Secret values for one execution so echoed values can be removed from outputs and errors that no longer retain Secret.Value.

func NewScrubber

func NewScrubber() *Scrubber

NewScrubber creates an empty execution-scoped Secret scrubber.

func (*Scrubber) Capture

func (scrubber *Scrubber) Capture(value any, target reflect.Type)

Capture records typed Secret values and, when target is provided, raw values occupying Secret-typed fields at a wire boundary.

func (*Scrubber) Clear

func (scrubber *Scrubber) Clear()

Clear releases references to captured values after the execution is complete.

func (*Scrubber) Sanitize

func (scrubber *Scrubber) Sanitize(value any) any

Sanitize redacts all captured values from value. If the bounded capture limit is exceeded, it redacts the complete result rather than risk an incomplete scrub.

func (*Scrubber) SanitizeError

func (scrubber *Scrubber) SanitizeError(err error) error

SanitizeError removes captured Secret values from err without exposing its original error chain when a value was changed.

type Value

type Value struct {
	// contains filtered or unexported fields
}

func New

func New(value string) Value

func (Value) Format

func (Value) Format(state fmt.State, verb rune)

func (Value) LogValue

func (Value) LogValue() slog.Value

func (Value) MarshalJSON

func (Value) MarshalJSON() ([]byte, error)

func (Value) MarshalText

func (Value) MarshalText() ([]byte, error)

func (*Value) UnmarshalJSON

func (*Value) UnmarshalJSON([]byte) error

func (*Value) UnmarshalText

func (*Value) UnmarshalText([]byte) error

Jump to

Keyboard shortcuts

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