envredact

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 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 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 Preview

func Preview(value string) string

Preview returns a short hint of value: at most four characters from each end, and nothing at all for values shorter than sixteen.

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.

Types

type Meta

type Meta struct {
	Sensitive     bool   `json:"sensitive"`
	Set           bool   `json:"set"`
	Preview       string `json:"preview,omitempty"`
	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