secret

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package secret masks credentials in text before it is written to the vault.

It started in internal/ingest, where a transcript is someone else's agent talking to a shell and routinely carries a pasted API key. But an agent writing a checkpoint, a working note or a memory pastes the same keys — "verified: the upload works with GITHUB_TOKEN=ghp_…" — and those paths went to the vault verbatim (#209). It is a leaf package so session and memory can use it without importing ingest, which imports them.

Two strengths, because the two kinds of text differ. A transcript is mostly machine output nobody chose to keep, so ingest also masks anything that merely looks random (MaskAll). An agent's own write is prose it chose, full of long mixed-case words — test names, module paths, identifiers with digits in them — that the entropy check can take for a key (#210 spares the plainest of them, not all) and that are the whole content of a verified line; there only a known credential shape is masked (Mask).

Index

Constants

View Source
const Marker = "[REDACTED]"

Marker replaces what was masked.

Variables

This section is empty.

Functions

func Summary

func Summary(found []Redaction) string

Summary is the sentence a receipt carries when something was masked, or "" when nothing was. It names where and why, never the value: an agent that pasted a key and is told only "saved" goes on believing the key is in the vault, or never learns it pasted one at all.

Types

type Redaction

type Redaction struct {
	Field  string // field the token was found in ("Commands", "Verified", ...)
	Reason string // why it matched
}

Redaction records one secret-shaped token that was masked, so the caller can announce it instead of leaving the fix invisible.

func Mask

func Mask(field, s string) (string, []Redaction)

Mask masks every substring of s that has a known credential shape. For text an agent chose to write: see the package comment for why it leaves high-entropy words alone. field is carried through only for the report.

func MaskAll

func MaskAll(field, s string) (string, []Redaction)

MaskAll is Mask plus any token that looks random enough to be a credential with no recognisable shape. For transcript text.

Jump to

Keyboard shortcuts

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