secretscan

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package secretscan detects likely secrets in file content and flags sensitive filenames before they are staged into git. It is deliberately conservative: high-confidence provider patterns and sensitive filenames always fire, while the generic high-entropy check is gated by an allowlist so that everyday source code stays quiet.

Index

Constants

View Source
const (
	RuleGitHubToken       = "github-token"
	RuleAWSAccessKey      = "aws-access-key"
	RulePrivateKey        = "private-key"
	RuleSlackToken        = "slack-token"
	RuleGoogleAPIKey      = "google-api-key"
	RuleStripeKey         = "stripe-key"
	RuleHighEntropyValue  = "high-entropy-value"
	RuleSensitiveFilename = "sensitive-filename"
)

Rule identifiers reported in Finding.Rule.

Variables

This section is empty.

Functions

func HasFindings

func HasFindings(content []byte, path string) bool

HasFindings reports whether Scan would flag the given content or path.

Types

type Finding

type Finding struct {
	// Rule is a short, stable identifier for the rule that matched
	// (for example "github-token" or "sensitive-filename").
	Rule string
	// Detail is a human-readable description shown to the user. It never
	// includes the secret value itself, only the rule and location.
	Detail string
	// Line is the 1-based line number for content matches, or 0 for a
	// match based on the filename alone.
	Line int
}

Finding describes one reason a file was flagged.

func Scan

func Scan(content []byte, path string) []Finding

Scan inspects file content and its path and returns any findings. Content scanning is skipped for binary data, but the filename rules still apply. The returned slice is nil when nothing is flagged.

Jump to

Keyboard shortcuts

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