sensitive

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sensitive holds a process-wide registry of secret values that must never appear in any log line, error message, or stdout output.

Usage:

token := os.Getenv("CLOUDFLARE_API_TOKEN")
sensitive.Register(token)            // ← BEFORE token reaches any code path that may log
scrubbed := sensitive.Scrub(message) // applied automatically by the shared Logger

Any value passed to Register is replaced with "***" wherever it appears in strings passed through Scrub. Values shorter than minRedactLen are ignored to avoid scrubbing common short tokens (e.g. account IDs that may legitimately appear in URLs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear empties the registry. Intended for tests.

func Fprint

func Fprint(w io.Writer, a ...any) (int, error)

Fprint scrubs and writes to w. Mirrors fmt.Fprint signature.

func Fprintf

func Fprintf(w io.Writer, format string, a ...any) (int, error)

Fprintf scrubs and writes to w. Mirrors fmt.Fprintf signature.

func Fprintln

func Fprintln(w io.Writer, a ...any) (int, error)

Fprintln scrubs and writes to w with a trailing newline.

func Print

func Print(a ...any) (int, error)

Print scrubs and writes to stdout. Mirrors fmt.Print signature.

func Printf

func Printf(format string, a ...any) (int, error)

Printf scrubs and writes to stdout. Mirrors fmt.Printf signature.

func Println

func Println(a ...any) (int, error)

Println scrubs and writes to stdout with a trailing newline.

func Register

func Register(values ...string)

Register adds value to the global redaction set. Safe for concurrent use. Values shorter than minRedactLen are silently ignored (avoids redacting short identifiers and breaking unrelated logs).

func Scrub

func Scrub(s string) string

Scrub returns s with every registered value replaced by "***" and every well-known credential pattern collapsed. Cheap when registry is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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