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
- func Args(args []string) (out []string, masked bool)
- func History(createdBy string) string
- func Line(s string) string
- func Lookup(env []string, name string) (string, bool)
- func Masked(name, value string) bool
- func SafeLabel(key, value string) bool
- func SecretName(name string) bool
- func URLCredentials(v string) bool
- type Label
- type Var
Constants ¶
const Mask = "••••••"
Mask replaces a masked part of a command argument.
Variables ¶
This section is empty.
Functions ¶
func Args ¶
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
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 ¶
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 ¶
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 ¶
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
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 ¶
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 ¶
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).