pii

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeOff       = "off"
	ModeCustomers = "customers"
	ModeAll       = "all"
)

Variables

This section is empty.

Functions

func EffectiveMode

func EffectiveMode(mode string, allowUnredacted bool, unredacted bool) (string, error)

EffectiveMode applies per-request override policy.

func IsEnabled

func IsEnabled(mode string) bool

func IsValidMode

func IsValidMode(v string) bool

func NormalizeMode

func NormalizeMode(v string) string

NormalizeMode normalizes configured mode values.

func ShouldRedactType

func ShouldRedactType(mode, entityType string) bool

ShouldRedactType decides whether an entity type should be redacted for mode. entityType is expected to be "customer" or "user". Unknown types are only redacted in "all" mode.

Types

type Engine

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

func NewEngine

func NewEngine(mode, secret string) *Engine

func (*Engine) Enabled

func (e *Engine) Enabled() bool

func (*Engine) Mode

func (e *Engine) Mode() string

func (*Engine) RedactEmail

func (e *Engine) RedactEmail(email string) string

func (*Engine) RedactJSON

func (e *Engine) RedactJSON(data json.RawMessage) (json.RawMessage, error)

func (*Engine) RedactPerson

func (e *Engine) RedactPerson(first, last, email string) (string, string, string)

func (*Engine) RedactPhone

func (e *Engine) RedactPhone(phone string) string

func (*Engine) RedactText

func (e *Engine) RedactText(text string, known []KnownIdentity) string

RedactText redacts free-form text using known identities followed by regex sweeps.

func (*Engine) ShouldRedactType

func (e *Engine) ShouldRedactType(entityType string) bool

type KnownIdentity

type KnownIdentity struct {
	Type  string
	First string
	Last  string
	Email string
	Phone string
}

Jump to

Keyboard shortcuts

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