redact

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package redact provides credential-pattern scrubbing for strings shipped to upstream LLM providers, log sinks, or persisted fields. The function set is intentionally regex-based (vs. structured parsing) so it MUST be applied as a defence-in-depth layer alongside structured payload design, not as the only credential filter.

Pattern set is derived from backend-security-design.md §3.1 (cross-language rule). Even imperfect regex is better than nothing — coverage > precision.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForLLM

func ForLLM(s string) string

ForLLM scrubs known credential patterns from s, replacing each match with a labelled placeholder. Empty input returns empty string. Order of patterns is fixed and deterministic so the same input always produces the same redacted output (useful for snapshot tests + log-based audit).

The function MUST stay cheap (called per-tool-invocation in the MCP middleware path); regexes are compiled once at package init.

Types

This section is empty.

Jump to

Keyboard shortcuts

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