Documentation
¶
Overview ¶
Package privacy strips secrets and sensitive material from memory content before storage, via pattern matching, entropy heuristics, and <private> tag removal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultFilterLevel = Moderate
DefaultFilterLevel is used by Filter() when no level is specified.
Functions ¶
func FilterWithLevel ¶
func FilterWithLevel(content string, level FilterLevel) string
FilterWithLevel replaces secrets in content with [REDACTED] at the specified level.
func IsLikelySecret ¶
IsLikelySecret heuristically determines if a token string is a secret.
Two shapes are treated as secrets:
- Mixed tokens with a moderate fraction of special characters (0.1–0.4), e.g. structured keys like "abc-123_def.ghi".
- Pure alphanumeric tokens with high Shannon entropy, e.g. hex digests and base64-without-padding random keys. These have a special-char ratio of ~0, so the ratio gate alone would never catch them — the dominant secret shape in practice.
Types ¶
type FilterLevel ¶
type FilterLevel int
FilterLevel controls how aggressively content is filtered.
const ( // Strict strips everything (emails, IPs, phones, secrets). Strict FilterLevel = iota // Moderate keeps infrastructure IPs (10.x, 192.168.x) and work-related emails. Moderate // Minimal only strips high-entropy secrets and explicit API keys. Minimal )
Click to show internal directories.
Click to hide internal directories.