Documentation
¶
Index ¶
Constants ¶
const (
// AbstractRegexpEngine describes the name of the used regular expression engine.
AbstractRegexpEngine = "std"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractRegexp ¶
type AbstractRegexp interface {
// MatchString reports whether the string s contains any match of the regular expression.
MatchString(s string) bool
// FindAllStringIndex returns a slice of all successive matches of the expression. A return value of nil
// indicates no match.
FindAllStringIndex(s string, n int) [][]int
// FindStringSubmatch returns a slice of strings holding the text of the leftmost match of the regular
// expression in s and the matches, if any, of its subexpressions. A return value of nil indicates no
// match.
FindStringSubmatch(s string) []string
}
AbstractRegexp is an abstract interface for a regular expression.
func CloneRegexp ¶
func CloneRegexp(re *regexp.Regexp) AbstractRegexp
CloneRegexp clones the given regular expression re.
func CompileRegexp ¶
func CompileRegexp(expr string) (AbstractRegexp, error)
CompileRegexp parses the given expression and returns, if successful, an AbstractRegexp.
func MustCompileRegexp ¶
func MustCompileRegexp(expr string) AbstractRegexp
MustCompileRegexp is like CompileRegexp but panics if the expression cannot be parsed. It simplifies safe initialization of global variables holding compiled abstract regular expressions.
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector wraps a set of rules to detect secrets.
func NewDetector ¶
func NewDetector(ruleFns []GitleaksRuleFunction, customs []string, enclosed bool) (*Detector, error)
NewDetector creates a new Detector object with rules from the given set of Gitleaks rule functions and additional custom rules.
type Finding ¶
type Finding struct {
RuleID string // ID of the rule responsible for the finding.
Description string // Description of the secret found.
Secret string // The actual secret.
Match string // The match containing the secret.
Location *Location // The location of the match.
}
Finding wraps all relevant information for a finding.
type GitleaksRuleFunction ¶
GitleaksRuleFunction is a function that generates a rule.
type Location ¶
type Location struct {
StartIdx int // Start index of the match
EndIdx int // End index of the match
StartLine int // Text line the start index falls in
EndLine int // Text line the end index falls in
StartColumn int // Column in the start line corresponding to the start index
EndColumn int // Column in the end line corresponding to the end index
StartLineIdx int // Index of the beginning of the start line
EndLineIdx int // Index of the first character after the end line
}
Location represents a location in a string.
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator allows to locate indexes in a string.
func NewLocator ¶
NewLocator creates a Locator object for the given string.
type Rule ¶
type Rule struct {
RuleID string // Unique identifier for this rule
Description string // Description of the rule
Entropy float64 // Minimum Shannon entropy a regex group must have to be considered a secret
SecretGroup int // Used to extract secret from regex match
Regex AbstractRegexp // Used to detect secrets
Allowlists []config.Allowlist // Allows a rule to be ignored for specific regexes, paths, and/or commits
}
Rule contains information that define details on how to detect secrets.
func NewRuleFromGitleaksRule ¶
NewRuleFromGitleaksRule creates a cleaned-up Rule object from a Gitlab's rule.