secrets

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package secrets masks the values the radiography shows (F7, spec §7): an environment variable whose name says it is a secret, or whose value is a URL with user information, never leaves the agent unless revealed.

Index

Constants

View Source
const Mask = "••••••"

Mask replaces a masked part of a command argument.

Variables

This section is empty.

Functions

func Args

func Args(args []string) (out []string, masked bool)

Args masks a command or an entrypoint (plan Observation, Q27), in a copy. The argument after a secret flag is masked whole: always after "--password=", unless it is a flag itself after "--requirepass". The argument after the "-c" of a shell (sh -c, bash -lc…) is a shell line: Line. Any other argument NAME=value or --name=value keeps its name and masks its whole value if the name is secret (blanks included), else the value goes through the rules of Line. masked tells whether anything was hidden.

func History added in v0.2.0

func History(createdBy string) string

History masks one line of an image's history (spec v0.2 §5.4). The build arguments of "|N NAME=value … /bin/sh -c …" are secrets whatever their name (GH_PAT, NPM_AUTH hold no word of §7): every value is masked up to the first " /bin/sh -c " or " /bin/bash -c ", the names stay (at most N of them). With "|1", the value runs to the shell, blanks included. With N ≥ 2, a value with a blank would make its next word pass for a name (review of tranche 5: "NPM_AUTH=Basic dXNl…==" let the base64 out): every word must be NAME=…, and there must be exactly N of them. Without a shell, with more than one, or on any other form, the whole part is masked (fail closed). Then the line goes through Line.

BuildKit also keeps "ARG NAME=value" with the value given by --build-arg, and "LABEL k=v …" without quotes (measured, Docker 29.7, tranche 5): the value of an ARG is masked (names alone, then one NAME=… at the end, else the whole part); a LABEL line keeps none of its text, since labels leave the agent through Labels only (spec v0.2 §7) and "a b=c d" cannot be cut into keys and values.

func Line

func Line(s string) string

Line masks one text (a message of Docker, a shell line): maskText, then, if a word of §7 is left with nothing masked after it, the whole text.

func Lookup

func Lookup(env []string, name string) (string, bool)

Lookup returns the value of variable name, exact name: the last one if it appears twice (Docker removes duplicates when it creates a container).

func Masked

func Masked(name, value string) bool

Masked: the variable must not be shown as is (spec §7): a secret name, or a value in which the rules of the command find something to mask (plan Observation, Q36: a URL with user information, "…;Pwd=…;", "?password=…", "-D…Password\=…", "--requirepass …"), the value read as is and percent-decoded ("?pass%77ord=…").

func SafeLabel added in v0.2.0

func SafeLabel(key, value string) bool

SafeLabel: the value of label key may be shown, by the whitelist of spec v0.2 §5.2 and by §7 (Masked), which still applies under the whitelist: a label set by hand under com.docker.compose. may hold anything.

func SecretName

func SecretName(name string) bool

SecretName: the name contains one of the words of spec §7, ignoring case (KEYBOARD and COMPASS too: the rule errs on the safe side).

func URLCredentials

func URLCredentials(v string) bool

URLCredentials: v holds a URL with user information.

Types

type Label added in v0.2.0

type Label struct {
	Key    string  `json:"key"`
	Value  *string `json:"value"`
	Masked bool    `json:"masked"`
}

Label is one label of a container (spec v0.2 §5.2). Value is nil when masked, as for a variable (spec §7: null with masked: true).

func Labels added in v0.2.0

func Labels(m map[string]string) []Label

Labels returns every label sorted by key: the value of a safe one (SafeLabel), the key alone for the others. There is no reveal of labels (Q60): their values can be read on the host with docker inspect.

type Var

type Var struct {
	Name   string  `json:"name"`
	Value  *string `json:"value"`
	Masked bool    `json:"masked"`
}

Var is one variable of the radiography. Value is nil when masked (spec §7: null with masked: true).

func Env

func Env(env []string) []Var

Env masks a Config.Env ("NAME=value"; "NAME" alone has an empty value), in order.

Jump to

Keyboard shortcuts

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