patterns

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package patterns is Harbor's V1 audit redactor driver. It composes the canonical rule set from internal/audit (key-based redaction for the seven secret shapes + bearer-in-value regex + multimodal detection) and applies every rule in deterministic order on every Redact call.

The driver self-registers under name "patterns" via init(); the runtime entry point cmd/harbor/main.go blank-imports this package to trigger registration. Other drivers (PII tokenizer, semantic redactor) plug in via the same registry seam without changing callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver is the patterns Redactor. Built once at boot via Open and shared across every emit path; D-025 concurrent-reuse contract is enforced by the test suite. The rule slice is immutable after construction.

func New

func New() *Driver

New constructs a Driver with the canonical V1 rule set. Exposed for tests that want to drive the redactor without round-tripping through the registry.

func NewWithRules

func NewWithRules(rules []audit.Rule) *Driver

NewWithRules constructs a Driver from an explicit rule set. Useful for tests that want to assert behaviour against a single rule.

func (*Driver) Names

func (d *Driver) Names() []string

Names returns the deterministic order in which this driver applies rules. Used by boot-log emission and by golden-file tests.

func (*Driver) Redact

func (d *Driver) Redact(ctx context.Context, payload any) (any, error)

Redact applies every rule in order. On the first error it returns (nil, wrapped error) — fail-loudly per audit.Redactor's contract. No partial payload is returned to the caller; the caller MUST NOT emit on error.

Jump to

Keyboard shortcuts

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