privacy

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 4 Imported by: 0

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 Filter

func Filter(content string) string

Filter replaces secrets in content with [REDACTED] using DefaultFilterLevel.

func FilterWithLevel

func FilterWithLevel(content string, level FilterLevel) string

FilterWithLevel replaces secrets in content with [REDACTED] at the specified level.

func IsLikelySecret

func IsLikelySecret(token string) bool

IsLikelySecret heuristically determines if a token string is a secret.

Two shapes are treated as secrets:

  1. Mixed tokens with a moderate fraction of special characters (0.1–0.4), e.g. structured keys like "abc-123_def.ghi".
  2. 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
)

Jump to

Keyboard shortcuts

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