redaction

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSensitiveKeys = map[string]struct{}{
	"token":         {},
	"passkey":       {},
	"password":      {},
	"auth":          {},
	"cookie":        {},
	"csrf":          {},
	"email":         {},
	"username":      {},
	"user":          {},
	"key":           {},
	"info_hash":     {},
	"anticsrftoken": {},
	"torrent_pass":  {},
	"popcron":       {},
}

DefaultSensitiveKeys is the JSON-key set used when a redaction call receives nil keys. Key matching ignores case and common separators and treats a key as sensitive when its normalized form contains a normalized entry.

Functions

func RedactPrivateInfo

func RedactPrivateInfo(data any, sensitiveKeys map[string]struct{}) any

RedactPrivateInfo recursively redacts JSON-like maps, slices, and strings without mutating input maps or slices. Nil keys use DefaultSensitiveKeys.

func RedactValue

func RedactValue(value string, sensitiveKeys map[string]struct{}) string

RedactValue redacts valid embedded JSON plus known secret-bearing URL, path, query, key/value, cookie, authorization, and long-hex patterns. Nil keys use DefaultSensitiveKeys for embedded JSON; textual patterns use the package's fixed secret vocabulary.

Types

type Block

type Block struct {
	Start int
	End   int
}

Block identifies a candidate JSON object's or array's half-open byte range within the source string.

func ExtractJSONBlocks

func ExtractJSONBlocks(text string) []Block

ExtractJSONBlocks returns balanced top-level object and array candidates in source order. Brackets inside quoted strings are ignored, and unterminated candidates are omitted.

Jump to

Keyboard shortcuts

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