secret

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package secret holds the one list of secret strings (repository passwords, notification URLs, API tokens) that must never reach a log line, an error message, or an API response (secrets must never leak).

A Set is shared by pointer between every component that redacts — the command runner, the pipeline, the scheduler, and the API — so a secret that first appears while the program is already running (a repository password generated for a new destination, a notification URL added after startup) is redacted everywhere the moment it is added, without restarting.

Index

Constants

View Source
const Placeholder = "[redacted]"

Placeholder replaces every redacted secret.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set is a concurrency-safe, growable list of secrets. A nil *Set is valid and redacts nothing.

func NewSet

func NewSet(values ...string) *Set

NewSet returns a Set holding values (empty strings are ignored).

func (*Set) Add

func (s *Set) Add(values ...string)

Add records more secrets. Empty strings and duplicates are ignored.

func (*Set) AddFile

func (s *Set) AddFile(path string)

AddFile records the contents of the secret file at path (surrounding whitespace trimmed, as many tools trim a password file). A missing or unreadable file adds nothing and is not an error: the command that actually uses the file reports that problem loudly; this only makes sure whatever that command can read is redacted. Calling it again after the file changed adds the new value too.

func (*Set) Redact

func (s *Set) Redact(text string) string

Redact replaces every occurrence of every secret in text with Placeholder, in a single pass: replaced text is never scanned again, and where secrets overlap the longest wins, so a secret that is a prefix of another cannot leave the longer one's tail visible (e.g. "https://ntfy.sh/abc" and "https://ntfy.sh/abc-photos").

func (*Set) Values

func (s *Set) Values() []string

Values returns a snapshot of every secret in s and its parents.

func (*Set) With

func (s *Set) With(extra ...string) *Set

With returns a child Set that redacts everything s redacts — including secrets added to s later — plus extra. s itself is not changed, so a caller can scope extra secrets to one command without leaking them into every other user of s.

Jump to

Keyboard shortcuts

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