redaction

package
v3.47.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package redaction provides an efficient configurable string redactor.

It is intended for internal use by buildkite-agent only.

Index

Constants

View Source
const RedactLengthMin = 6

RedactLengthMin is the shortest string length that will be considered a potential secret by the environment redactor. e.g. if the redactor is configured to filter out environment variables matching *_TOKEN, and API_TOKEN is set to "none", this minimum length will prevent the word "none" from being redacted from useful log output.

Variables

This section is empty.

Functions

func GetKeyValuesToRedact

func GetKeyValuesToRedact(logger shell.Logger, patterns []string, environment map[string]string) map[string]string

Given a redaction config string and an environment map, return the list of values to be redacted. Lifted out of Bootstrap.setupRedactors to facilitate testing

func GetValuesToRedact

func GetValuesToRedact(logger shell.Logger, patterns []string, environment map[string]string) []string

Types

type Redactor

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

func NewRedactor

func NewRedactor(output io.Writer, replacement string, needles []string) *Redactor

Construct a new Redactor, and pre-compile the Boyer-Moore skip table

func (*Redactor) Flush

func (redactor *Redactor) Flush() error

Flush should be called after the final Write. This will Write() anything retained in case of a partial match and reset the output buffer.

func (*Redactor) Reset

func (redactor *Redactor) Reset(needles []string)

We re-use the same Redactor between different hooks and the command We need to reset and update the list of needles between each phase

func (*Redactor) Write

func (redactor *Redactor) Write(input []byte) (int, error)

type RedactorMux

type RedactorMux []*Redactor

func (RedactorMux) Flush

func (mux RedactorMux) Flush() error

Flush flushes all redactors

func (RedactorMux) Reset

func (mux RedactorMux) Reset(needles []string)

Reset resets all redactors with new needles (secrets)

Jump to

Keyboard shortcuts

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