mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
feat(rule): validate & sort rule when generating (#1817)
This commit is contained in:
1 parent
107a41827b
commit
cfdeb0d7e0
18 files changed
+145
-115
No files matched your search
+6
-8
@@ -67,7 +67,7 @@ type Config struct {
|
||||
Path string
|
||||
Description string
|
||||
Rules map[string]Rule
|
||||
Allowlist Allowlist
|
||||
Allowlist *Allowlist
|
||||
Keywords map[string]struct{}
|
||||
|
||||
// used to keep sarif results consistent
|
||||
@@ -164,17 +164,15 @@ func (vc *ViperConfig) Translate() (Config, error) {
|
||||
allowlistPaths = append(allowlistPaths, regexp.MustCompile(a))
|
||||
}
|
||||
|
||||
allowlist := Allowlist{
|
||||
allowlist := &Allowlist{
|
||||
Description: a.Description,
|
||||
MatchCondition: condition,
|
||||
Commits: a.Commits,
|
||||
Paths: allowlistPaths,
|
||||
RegexTarget: a.RegexTarget,
|
||||
Regexes: allowlistRegexes,
|
||||
Paths: allowlistPaths,
|
||||
Commits: a.Commits,
|
||||
StopWords: a.StopWords,
|
||||
}
|
||||
if err := allowlist.Validate(); err != nil {
|
||||
return Config{}, fmt.Errorf("%s: %w", cr.RuleID, err)
|
||||
}
|
||||
cr.Allowlists = append(cr.Allowlists, allowlist)
|
||||
}
|
||||
orderedRules = append(orderedRules, cr.RuleID)
|
||||
@@ -192,7 +190,7 @@ func (vc *ViperConfig) Translate() (Config, error) {
|
||||
Description: vc.Description,
|
||||
Extend: vc.Extend,
|
||||
Rules: rulesMap,
|
||||
Allowlist: Allowlist{
|
||||
Allowlist: &Allowlist{
|
||||
RegexTarget: vc.Allowlist.RegexTarget,
|
||||
Regexes: allowlistRegexes,
|
||||
Paths: allowlistPaths,
|
||||
|
||||
Reference in new issue
Block a user