secrets

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTextFile

func IsTextFile(path string) bool

IsTextFile returns true if a file is likely to be a text file.

func MaskAll

func MaskAll(content string) string

MaskAll applies secret key block masking (multiline) then per-line masking (password, tokens, etc).

func MaskLine

func MaskLine(line string) string

func MaskSecretKeyBlocks

func MaskSecretKeyBlocks(content string) string

MaskSecretKeyBlocks replaces entire private key PEM/OPENSSH blocks with *****MASKED*****

Types

type RuleSet

type RuleSet struct {
	Patterns []*regexp.Regexp // Default+Added patterns (order matters!)
	Allowed  []*regexp.Regexp
}

RuleSet holds a set of forbidden/allowed patterns.

func DefaultRuleSet

func DefaultRuleSet() *RuleSet

New default ruleset (defaultPatterns at front, then AddPattern, order preserved)

func (*RuleSet) AddAllowed

func (r *RuleSet) AddAllowed(pattern string) error

func (*RuleSet) AddPattern

func (r *RuleSet) AddPattern(pattern string) error

func (*RuleSet) ScanDir

func (r *RuleSet) ScanDir(root string, recursive bool) ([]SecretMatch, error)

func (*RuleSet) ScanFile

func (r *RuleSet) ScanFile(path string) ([]SecretMatch, error)

func (*RuleSet) ScanReader

func (r *RuleSet) ScanReader(rd io.Reader, filename string) ([]SecretMatch, error)

ScanReader returns all matches for forbidden patterns (order=priority!).

type SecretMatch

type SecretMatch struct {
	File    string
	Line    int
	Text    string
	Pattern string
}

SecretMatch holds information about a detected secret in a file.

Jump to

Keyboard shortcuts

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