mask

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package mask defines field masking for sensitive data. A Masker applies a named rule (configured per attribute) to a value before it is returned, instead of excluding the column outright — so the agent sees shape, not secrets (e.g. email -> "a***@x.com"). Masking never raises: an unknown rule passes the value through unchanged so a misconfiguration cannot break reads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuiltinRules added in v0.1.11

func BuiltinRules() []string

BuiltinRules returns the names of the built-in mask rules, sorted.

Types

type Masker

type Masker interface {
	Mask(rule string, value any) any
}

Masker applies a named masking rule to a value. Implementations must not panic on unknown rules or nil values.

type NoopMasker

type NoopMasker struct{}

NoopMasker passes values through unchanged; used when masking is disabled.

func (NoopMasker) Mask

func (NoopMasker) Mask(_ string, value any) any

Mask implements Masker by returning the value unchanged.

type Rule

type Rule func(value any) any

Rule masks a single non-nil value.

type RuleMasker

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

RuleMasker maps rule names to Rules. The zero value masks nothing.

func NewRuleMasker

func NewRuleMasker() *RuleMasker

NewRuleMasker returns a Masker with the built-in rules (email, phone, idcard, secret).

func (*RuleMasker) Has

func (m *RuleMasker) Has(name string) bool

Has reports whether a rule name is registered. Assemblers call it to reject a misconfigured mask rule at startup rather than silently leaking plaintext at read time.

func (*RuleMasker) Mask

func (m *RuleMasker) Mask(rule string, value any) any

Mask applies the named rule. An unknown rule or nil value passes through unchanged; assemblers reject unknown rule names at startup (see Has).

Jump to

Keyboard shortcuts

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