mask

package
v0.11.691 Latest Latest
Warning

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

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

Documentation

Overview

Package mask redacts credential values from log output by searching for each secret in every form it can appear as (raw, escaped, base64) and replacing it.

Index

Constants

View Source
const Mask = "****"

Mask is the placeholder written in place of a credential value.

Variables

This section is empty.

Functions

func InlineSensitiveValues

func InlineSensitiveValues(conn any) []string

InlineSensitiveValues returns only inline `sensitive:"true"` values, without reading any sensitive_file paths — used to mask every configured connection cheaply while leaving credential files to the used-connection pass.

func SensitiveValues

func SensitiveValues(conn any) (values, unreadable []string)

SensitiveValues returns inline `sensitive:"true"` values and the CONTENTS of `sensitive_file:"true"` paths in conn; unreadable lists set-but-unreadable paths.

Types

type LineWriter

type LineWriter struct {
	// contains filtered or unexported fields
}

LineWriter masks output, always holding back a trailing window the width of the longest secret form so a secret split across writes is masked whole, not leaked.

func (*LineWriter) Flush

func (lw *LineWriter) Flush() error

Flush masks and writes the retained trailing bytes.

func (*LineWriter) Write

func (lw *LineWriter) Write(p []byte) (int, error)

type Masker

type Masker struct {
	// contains filtered or unexported fields
}

Masker masks a fixed set of secret forms in arbitrary text.

func New

func New(values []string) *Masker

New builds a Masker from raw secret values, expanding each into the forms it can appear as (raw, query/path/userinfo-escaped, base64).

func (*Masker) Empty

func (r *Masker) Empty() bool

Empty reports whether there is nothing to mask.

func (*Masker) Mask

func (r *Masker) Mask(s string) string

Mask replaces every known secret form found in s with the placeholder.

func (*Masker) Writer

func (r *Masker) Writer(w io.Writer) *LineWriter

Writer wraps w in a masking writer. Call Flush once writing is done to emit the retained trailing bytes.

Jump to

Keyboard shortcuts

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