secrets

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package secrets provides a lightweight, dependency-free scanner for high-confidence secret patterns (cloud keys, provider tokens, private keys, JWTs). It complements the boundary scrubbing of the configured API key by catching OTHER secrets that a command or diff happens to print, so they are not echoed back into the model context. It deliberately favors precision over recall: only well-shaped, distinctive patterns match, to avoid false positives on ordinary output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	Type  string // category, e.g. "aws_access_key_id"
	Match string // the exact matched text (used for redaction)
}

Finding is one detected secret occurrence.

func Redact

func Redact(text string) (string, []Finding)

Redact replaces every detected secret in text with a typed placeholder and returns the redacted text plus the findings. When nothing matches it returns the input unchanged and a nil slice.

func Scan

func Scan(text string) []Finding

Scan returns the distinct secrets found in text (deduplicated by match, sorted by type then match for deterministic output).

Jump to

Keyboard shortcuts

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