Documentation
¶
Index ¶
- Constants
- func EffectiveMode(mode string, allowUnredacted bool, unredacted bool) (string, error)
- func IsEnabled(mode string) bool
- func IsValidMode(v string) bool
- func NormalizeMode(v string) string
- func ShouldRedactType(mode, entityType string) bool
- type Engine
- func (e *Engine) Enabled() bool
- func (e *Engine) Mode() string
- func (e *Engine) RedactEmail(email string) string
- func (e *Engine) RedactJSON(data json.RawMessage) (json.RawMessage, error)
- func (e *Engine) RedactPerson(first, last, email string) (string, string, string)
- func (e *Engine) RedactPhone(phone string) string
- func (e *Engine) RedactText(text string, known []KnownIdentity) string
- func (e *Engine) ShouldRedactType(entityType string) bool
- type EngineOption
- type KnownIdentity
- type NameDetector
- type NameSpan
Constants ¶
const ( ModeOff = "off" ModeCustomers = "customers" ModeAll = "all" )
const RedactTextNotice = `[redacted — run "hs pii-model install" for content]`
RedactTextNotice is shown for freeform text when NER is not installed.
Variables ¶
This section is empty.
Functions ¶
func EffectiveMode ¶
EffectiveMode applies per-request override policy.
func IsValidMode ¶
func NormalizeMode ¶
NormalizeMode normalizes configured mode values.
func ShouldRedactType ¶
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, opts ...EngineOption) *Engine
func (*Engine) RedactEmail ¶
func (*Engine) RedactJSON ¶
func (e *Engine) RedactJSON(data json.RawMessage) (json.RawMessage, error)
func (*Engine) RedactPerson ¶
func (*Engine) RedactPhone ¶
func (*Engine) RedactText ¶
func (e *Engine) RedactText(text string, known []KnownIdentity) string
RedactText redacts free-form text using known identities followed by regex sweeps. When NER is available, names are detected via ML. Without NER, freeform text is hidden entirely (structured field redaction still works).
In mode-restricted operation (e.g. "customers"), only identities whose Type matches the mode are redacted; other known identities are "protected" so neither redactKnown nor NER replaces them.
func (*Engine) ShouldRedactType ¶
type EngineOption ¶ added in v0.2.0
type EngineOption func(*Engine)
EngineOption configures optional Engine behaviour.
func WithNER ¶ added in v0.2.0
func WithNER(d NameDetector) EngineOption
WithNER attaches a name detector for freeform text redaction.
type KnownIdentity ¶
type NameDetector ¶ added in v0.2.0
NameDetector detects person names in free-form text.