Documentation
¶
Overview ¶
Package mask hides secret values in everything Probe prints or writes.
Index ¶
Constants ¶
const MinLength = 4
MinLength is the fewest characters a value must have to be masked inside other text. A shorter value, such as 1, ok or dev, is as likely to stand inside an unrelated word as for itself: replacing it wherever it appears mangles the whole output, and the letters missing from the words give it away anyway. Such a value is masked only where it is a whole value of a request or a response, which neither mangles nor gives away anything. A credential header or parameter shown by Map, and the password in a URL under dsn or url, are still replaced outright, whatever their length, since that depends on their names, not their values.
Variables ¶
This section is empty.
Functions ¶
func HoldsCredential ¶
HoldsCredential reports whether the parameter or header named key holds a credential, whole or, as a database URL does, in part. A message about such a value, such as why its template could not be evaluated, must not show what was written there.
Types ¶
type Masker ¶
type Masker struct {
// contains filtered or unexported fields
}
Masker hides secret values in everything Probe prints or writes. It starts with the secrets the workflow declares and learns the values of credential headers as actions are about to send them, so that a token obtained at run time is hidden too. A nil Masker hides only credential headers in the maps passed to Map, and learns nothing.
func New ¶
New builds a Masker for the environment variables named in secrets. Each value is replaced by <secret:NAME>. A name that is not set, or set to an empty string, has nothing to hide and is skipped. A value shorter than MinLength is masked only where it is a whole value; TooShort names those secrets so that the caller can warn about them.
func (*Masker) Learn ¶
Learn registers the values of credential headers and parameters found anywhere in data, and the password in a database URL, so that they are hidden from then on. It is called with an action's parameters before the action runs, which is what keeps them out of the action's own log records.
func (*Masker) Map ¶
Map returns a copy of a request or response with secret values hidden in every string, and the values of credential headers replaced outright. The original is left untouched, since tests and outputs still need the real values. A nil map stays nil.
func (*Masker) String ¶
String hides every secret value in s, and the credentials of every URL in it. The values go first, so that a secret is replaced whole with its label and its name is kept, also when it stands in a URL: a scan of the URL could otherwise cut it at a quote it holds and leave the rest visible.
func (*Masker) TooShort ¶ added in v1.30.0
TooShort returns the names of the declared secrets whose values are set but shorter than MinLength, and so are masked only where they are a whole value, once each in the order they were declared. It never returns the values.
func (*Masker) Value ¶
Value returns v, a value read out of a request or a response, with secret values hidden in every string at any depth, as Map hides them in a whole one. The original is left untouched.