mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
31 lines
519 B
Go
31 lines
519 B
Go
package config
|
|
|
|
import "regexp"
|
|
|
|
type Allowlist struct {
|
|
Description string
|
|
Regexes []*regexp.Regexp
|
|
Paths []*regexp.Regexp
|
|
Commits []string
|
|
}
|
|
|
|
func (a *Allowlist) CommitAllowed(c string) bool {
|
|
if c == "" {
|
|
return false
|
|
}
|
|
for _, commit := range a.Commits {
|
|
if commit == c {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (a *Allowlist) PathAllowed(path string) bool {
|
|
return anyRegexMatch(path, a.Paths)
|
|
}
|
|
|
|
func (a *Allowlist) RegexAllowed(s string) bool {
|
|
return anyRegexMatch(s, a.Regexes)
|
|
}
|