redact

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package redact masks credential-bearing values so they don't reach logs, error messages, or anywhere else go-make prints. It centralizes the rules so the name denylist and the secret-shape patterns live in exactly one place rather than drifting across the run, fetch, and github packages.

Index

Constants

View Source
const Mask = "***"

Mask is the placeholder substituted for a redacted value.

Variables

This section is empty.

Functions

func Args

func Args(args []string) []string

Args returns a copy of args with credential-looking values masked, suitable for logging a command line. It handles two shapes:

  • "name=value" / "--flag=value": the value is masked when the key looks sensitive AND the value is non-empty (an empty value is not a secret, so e.g. "credential.helper=" is left readable).
  • "--flag" followed by a separate value token: the following token is masked when the flag looks sensitive (e.g. "--token", "secret").

A bare positional secret cannot be detected by name and passes through unchanged — callers must avoid putting raw secrets in positional arguments.

func IsSensitiveName

func IsSensitiveName(name string) bool

IsSensitiveName reports whether name looks like it holds a credential.

func Secrets

func Secrets(s string) string

Secrets scrubs known credential shapes out of an arbitrary string. Use it for content that may contain secrets but isn't keyed by name — command output captured on failure, fetched URLs, and the like. It is best-effort by design: it masks the shapes go-make actually handles (GitHub tokens, Authorization headers, URL userinfo) and cannot catch an arbitrary opaque secret.

func Value

func Value(name, value string) string

Value returns Mask when name looks sensitive, otherwise value unchanged. Use it wherever a value is keyed by a name (env entry, header, config key).

Types

This section is empty.

Jump to

Keyboard shortcuts

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