envredact

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

View Source
const (
	ReasonName     = "name"
	ReasonValue    = "value"
	ReasonOverride = "override"
	ReasonPublic   = "public"
)

Reasons a value was classified sensitive or plain.

View Source
const Marker = "[redacted]"

Marker replaces a known secret found inside free text.

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

func Classify(key, value string, override *bool) (sensitive bool, reason string)

Classify reports whether key=value is sensitive and why. override, when non-nil, is the operator's explicit choice and always wins.

func IsPlaceholder

func IsPlaceholder(v string) bool

IsPlaceholder reports whether v is the masked placeholder.

func IsPublicName

func IsPublicName(key string) bool

IsPublicName reports whether key carries a browser-public framework prefix.

func Map

func Map(env map[string]string, overrides map[string]bool) (map[string]string, map[string]Meta)

Map masks every sensitive value in env. The input map is never mutated.

func Merge

func Merge(submitted, stored map[string]string) (map[string]string, error)

Merge resolves a submitted env against the stored one: a Placeholder keeps the stored value, and a Placeholder with nothing stored fails.

func Secrets

func Secrets(s string, secrets ...string) string

Secrets replaces every non-empty secret found in s with Marker.

func SensitiveName

func SensitiveName(key string) bool

SensitiveName reports whether key's name alone marks it sensitive.

func SensitiveValue

func SensitiveValue(key, value string) bool

SensitiveValue reports whether value looks like key material on its own.

func URLForLog

func URLForLog(raw string) string

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

func URLQuery(raw string, keys map[string]bool, mask string) string

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

func URLUserinfo(raw, username string) (string, error)

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.

func Value

func Value(key, value string, overrides map[string]bool) (string, Meta)

Value returns what a read surface may show for key=value and its meta.

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

Jump to

Keyboard shortcuts

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