secrets

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
	HexChars    = "1234567890abcdefABCDEF"
)

Variables

This section is empty.

Functions

func CheckEntropyInterval

func CheckEntropyInterval(entropy Entropy, token string) (isEntropyInInterval bool, entropyLevel float64)

CheckEntropyInterval - verifies if a given token's entropy is within expected bounds

func MaskSecrets

func MaskSecrets(fileContent string) (string, []maskedSecret.MaskedSecret, error)

Types

type AllowRule

type AllowRule struct {
	Description string `json:"description"`
	Regex       string `json:"regex"`
}

type Entropy

type Entropy struct {
	Group int     `json:"group"`
	Min   float64 `json:"min"`
	Max   float64 `json:"max"`
}

type Multiline

type Multiline struct {
	DetectLineGroup int `json:"detectLineGroup"`
}

type Result

type Result struct {
	QueryName string `json:"queryName"`
	Line      int    `json:"line"`
	FileName  string `json:"fileName"`
	Severity  string `json:"severity"`
}

func ReplaceMatches

func ReplaceMatches(fileName string, result string, regexs []SecretRegex, allowRegexes []*regexp.Regexp) (string, []Result, []maskedSecret.MaskedSecret)

ReplaceMatches If matches between the regex and the file content, then replace the match with the string "<masked>"

type SecretRegex

type SecretRegex struct {
	QueryName   string
	Regex       *regexp.Regexp
	Multiline   Multiline
	Entropies   []Entropy
	AllowRules  []*regexp.Regexp
	SpecialMask *regexp.Regexp
}

func LoadRegexps

func LoadRegexps() ([]SecretRegex, []*regexp.Regexp, error)

LoadRegexps Load custom regexps

type SecretRule

type SecretRule struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Regex       string      `json:"regex"`
	Entropies   []Entropy   `json:"entropies"`
	Multiline   Multiline   `json:"multiline"`
	AllowRules  []AllowRule `json:"allowRules"`
	SpecialMask string      `json:"specialMask"`
}

type SecretRules

type SecretRules struct {
	Rules      []SecretRule `json:"rules"`
	AllowRules []AllowRule  `json:"allowRules"`
}

Jump to

Keyboard shortcuts

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