secrets

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package secrets detects (and optionally redacts) likely credentials in session content — API keys, tokens, private keys — so you can check a session before sharing or syncing it. Detection is best-effort and pattern-based: it favours high-signal patterns to keep false positives low, and never phones home.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasSecrets

func HasSecrets(content []byte) bool

HasSecrets is a quick yes/no.

func Redact

func Redact(content []byte) ([]byte, int)

Redact replaces every detected secret with a typed placeholder and reports how many were replaced. It is lossy and opt-in. Private-key blocks are replaced only at their header (the body is left, since the header alone signals the secret and rewriting multi-line PEM bodies risks corrupting structure); callers that need full-body redaction should drop the whole value.

Types

type Finding

type Finding struct {
	Type   string // human label, e.g. "AWS access key"
	Masked string // the match with the middle replaced by ***
}

Finding is one detected secret, with the value masked for safe display.

func Scan

func Scan(content []byte) []Finding

Scan returns the distinct secrets found in content (masked). Duplicates of the same masked value+type are collapsed.

Jump to

Keyboard shortcuts

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