redact

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package redact removes sensitive values from connector configurations before they are persisted to the state file or written to logs. Redaction is always-on and one-way: the original value is never recoverable from the redacted output. Matching is fail-closed — a key that looks sensitive is redacted even at the cost of occasionally redacting a benign value.

Index

Constants

View Source
const Placeholder = "<kcp-redacted>"

Placeholder is the literal value substituted for a redacted config value.

Variables

This section is empty.

Functions

func AnyMapContainsRedacted

func AnyMapContainsRedacted(in map[string]any) bool

AnyMapContainsRedacted reports whether any value in in has already been redacted, recursing into nested maps and lists so that placeholders buried in structured values are also found. As with MapContainsRedacted, a value counts only when it equals Placeholder exactly. A nil or empty map yields false. The input is not mutated.

func IsSensitive

func IsSensitive(key string) bool

IsSensitive reports whether a config key should have its value redacted. A key is sensitive if any blacklist entry (a static sensitive-config name or a broad pattern) appears as a case-insensitive substring of the key.

func MapContainsRedacted

func MapContainsRedacted(in map[string]string) bool

MapContainsRedacted reports whether any value in in has already been redacted, i.e. equals Placeholder exactly. Matching is exact-equality (not substring) because redaction replaces the whole value, so a benign value that merely embeds the placeholder text is not treated as redacted. A nil or empty map yields false. The input is not mutated.

func RedactAnyMap

func RedactAnyMap(in map[string]any) (map[string]any, int)

RedactAnyMap returns a copy of in with sensitive values replaced by Placeholder, plus the number of values redacted. It recurses into nested maps and lists so that secrets nested inside structured values are also caught. A sensitive key is redacted wholesale regardless of its value's type (fail-closed); non-sensitive keys whose values are containers are recursed into. The input is not mutated.

func RedactStringMap

func RedactStringMap(in map[string]string) (map[string]string, int)

RedactStringMap returns a copy of in with the values of sensitive keys replaced by Placeholder, plus the number of values redacted. The input map is not mutated. A nil input yields an empty map and a count of zero.

Types

This section is empty.

Jump to

Keyboard shortcuts

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