redact

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package redact masks resolved secret values out of log output.

Skill secrets (RMI-OMNIAGENT-200/201/202) are resolved once from a vault and then threaded into MCP subprocess environments, OpenAPI auth headers, and compiled-skill env maps (RMI-OMNIAGENT-203/209/210). None of those paths intentionally log the resolved value, but nothing previously stopped a future debug line — or a naive %v/%+v dump of a skill's internal config — from leaking one. Register call sites register each resolved value here; NewHandler wraps a slog.Handler so any log record containing a registered value has it masked before it reaches the underlying handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(next slog.Handler) slog.Handler

NewHandler wraps next so records it handles have registered secret values masked first.

func Register

func Register(vals ...string)

Register adds resolved secret values to the redaction set. Empty values and values shorter than minSecretLen are ignored. Safe for concurrent use.

func Reset

func Reset()

Reset clears the registry. Test-only — production call sites only ever add values as secrets are resolved.

func String

func String(s string) string

String replaces every occurrence of a registered value in s with a mask.

Types

type Handler

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

Handler wraps an slog.Handler, masking registered secret values out of the message and every attribute (including nested groups) of each record.

func (*Handler) Enabled

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

Enabled implements slog.Handler.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) error

Handle implements slog.Handler.

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs implements slog.Handler.

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

WithGroup implements slog.Handler.

Jump to

Keyboard shortcuts

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