Documentation
¶
Overview ¶
Package secretscan finds API keys and other secrets in files about to be committed, for the pre-commit hook a harness gets (spec_051_secret_hooks): known key formats anywhere, and long random values assigned to key-like names in .env and config files. A line with "blitz:allow-secret" is skipped (a false alarm, a test fixture).
Index ¶
Constants ¶
const ( // Installed: the hook was written and core.hooksPath set. Installed = "installed" // Present: the repository already has it. Present = "present" // OtherHooks: the repository uses other hooks (core.hooksPath set // elsewhere, husky, the pre-commit framework, a .git/hooks/pre-commit); // nothing was changed. Detail says which. OtherHooks = "other_hooks" )
Install results.
const AllowMarker = "blitz:allow-secret"
AllowMarker on a line skips it.
const HookScript = `` /* 1364-byte string literal not displayed */
HookScript is .githooks/pre-commit: Blitz's scan when blitz is on PATH, else a portable search of the lines being added for the same key formats.
const HooksDir = ".githooks"
HooksDir is where the hook goes, relative to the repository's top: versioned, so everyone who clones it gets it (core.hooksPath).
Variables ¶
var ErrNotARepository = errors.New("not a git repository")
ErrNotARepository is Install outside a git repository.
Functions ¶
Types ¶
type Finding ¶
type Finding struct {
Path string
Line int
// Kind names what it looks like ("AWS access key").
Kind string
// Masked is the value with all but its first four characters hidden.
Masked string
}
A Finding is a secret on a line of a file.
func History ¶ added in v0.9.0
func History(ctx context.Context, dir, ref string, maxFiles int) (found []Finding, complete bool, err error)
History finds the secrets in every file of the history ref has in the repository at dir (each version of each file once, those under 1 MB), for a repository about to be shared: its past commits go with it. At most maxFiles files are read (folders don't count); complete says whether that was all of them. A version seen at several paths is read as a settings file when one of them is one (.env, a .json…), where a long random value assigned to a key-like name is a secret.