masker

package
v0.44.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Masker added in v0.38.0

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

Masker handles the creation and synchronization of streams that have all their writes scanned for secrets and have them redacted if any matches are found. Masking of secrets is a best effort attempt. Output on all streams is buffered to increase the chance of finding secrets if they are spread across multiple writes, but it cannot be guaranteed that these secrets are masked. The duration bytes spend in the buffer is constant.

Usage: 1. Create a new Masker using New() 2. Add one more streams using AddStream() 3. Run the Start() method in a separate goroutine 4. After everything has been written to the io.Writers, flush all buffers using Stop()

func New added in v0.38.0

func New(sequences [][]byte, opts *Options) *Masker

New creates a new Masker that scans all streams for the given sequences and masks them.

func (*Masker) AddStream added in v0.38.0

func (m *Masker) AddStream(w io.Writer) io.Writer

AddStream takes in an io.Writer to mask secrets on and returns an io.Writer that has secrets on its output masked.

func (*Masker) Start added in v0.38.0

func (m *Masker) Start()

Start continuously flushes the input buffer for each frame for which the buffer delay has passed. This method blocks until Stop() is called.

func (*Masker) Stop added in v0.38.0

func (m *Masker) Stop() error

Stop all pending frames and wait for this to complete. This should be run after all input has been written to the io.Writers of the streams. Calling Write() on a stream after calling Stop() will lead to a panic.

type Options added in v0.38.0

type Options struct {
	// DisableBuffer completely disables the buffering of the masker. This increases output responsiveness
	// but also increases the chance of a secret not being masked.
	DisableBuffer bool

	// BufferDelay is the constant duration for which input to a stream is buffered. A higher value increases
	// the chance of secrets being detected for masking. Especially when writes have a variable delay between them,
	// for example in the case data arrives over an unstable network connection.
	// Defaults to 50ms if not set.
	BufferDelay time.Duration

	// FrameBufferLength is the number of frames that can be in the buffer simultaneously.
	// If the frame buffer is full, writing to a stream blocks until there is space.
	FrameBufferLength int
}

Options for configuring masking behavior.

Jump to

Keyboard shortcuts

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