redact

package
v0.183.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package redact replaces credentials and payment details in text with a placeholder that names what was there: "[redacted: card number]".

Second Brain keeps what sessions said and hands it on — to later sessions, to other projects' screens, to agents through `caprock mcp` — so a key or a card number that lands in a memory spreads. Its store runs every memory through Text before it is saved, and the MCP server runs every answer through it before it leaves.

Precision matters as much as recall: a memory full of "[redacted]" where a commit, a UUID, a version or a price was is a memory nobody can use. So a shape alone is trusted only where the shape is distinctive (an `sk-ant-` key, a PEM block); a bare number is a card only when it passes Luhn with a card network's prefix, an IBAN only when its mod-97 checksum holds, and anything else — an account number, a password, a hex secret — only after a label that says what it is.

Index

Constants

View Source
const (
	KindPrivateKey  = "private key"
	KindAPIKey      = "api key"
	KindToken       = "token"
	KindCard        = "card number"
	KindIBAN        = "iban"
	KindPassword    = "password"
	KindSecret      = "secret"
	KindBankAccount = "bank account"
)

Kinds, as the placeholder names them.

Variables

This section is empty.

Functions

func Placeholder

func Placeholder(kind string) string

Placeholder is what a value of kind is replaced with.

func String

func String(s string) string

String is Text without the counts.

Types

type Counts

type Counts map[string]int

Counts is how many values of each kind a call replaced.

func Strings

func Strings(in []string) ([]string, Counts)

Strings runs Text over each of in, returning a new slice and the counts.

func Text

func Text(s string) (string, Counts)

Text returns s with every value a rule finds replaced by its placeholder, and how many of each kind it replaced. Text that holds nothing comes back unchanged, the same string.

func (Counts) Add

func (c Counts) Add(o Counts)

Add folds o into c.

func (Counts) String

func (c Counts) String() string

String is "card number=1 token=2", kinds sorted: for a log line.

func (Counts) Total

func (c Counts) Total() int

Total is the sum over every kind.

Jump to

Keyboard shortcuts

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