secrets

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 4 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 secrets finds credentials in text. It is shared by the repo file scanner and the scanner that checks records before they are written.

Index

Constants

View Source
const (
	MinEntropy = 3.5
	MinLength  = 20
)

The entropy rule for a value assigned to a credential-named variable.

Variables

This section is empty.

Functions

func Entropy

func Entropy(s string) float64

Entropy returns the Shannon entropy of a string in bits per character.

func HighEntropy

func HighEntropy(v string) bool

HighEntropy applies the rule for a value with no known prefix.

func LooksLikeSecret

func LooksLikeSecret(v string) bool

LooksLikeSecret is the record scanner's test for one value.

Types

type Classes

type Classes struct {
	ProdWords    []string
	StagingWords []string
	ExamplePaths []string
}

Classes decide what environment a file belongs to.

func DefaultClasses

func DefaultClasses() Classes

DefaultClasses are the built-in rules. Config can add to them.

func (Classes) Class

func (c Classes) Class(p string) string

Class returns prod, staging, example or unknown for a file path. Words match whole, so product/ is not prod.

type Finding

type Finding struct {
	Kind  string
	Line  int
	Value string
	KeyID string // AWS access key ID, an identifier and never the secret
}

Finding is one credential in a file. Value is held in memory only, to be hashed, and must never be stored.

func Scan

func Scan(text string) []Finding

Scan finds credentials in a file's text, by known prefix, and by variable name with a high-entropy value assigned or given as a default. Code references such as env.X and calls are not values, a value ends at a backslash escape, and values with a placeholder word are skipped.

Jump to

Keyboard shortcuts

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