|
@@ -50,12 +50,6 @@ type ViperConfig struct {
|
|
|
// TODO: Remove this in 9.x.
|
|
// TODO: Remove this in 9.x.
|
|
|
AllowList *viperGlobalAllowlist
|
|
AllowList *viperGlobalAllowlist
|
|
|
Allowlists []*viperGlobalAllowlist
|
|
Allowlists []*viperGlobalAllowlist
|
|
|
-
|
|
|
|
|
- // EnableExperimentalAllowlistOptimizations enables a preview feature.
|
|
|
|
|
- // See: https://github.com/gitleaks/gitleaks/pull/1731
|
|
|
|
|
- //
|
|
|
|
|
- // NOTE: This flag may be removed in the future.
|
|
|
|
|
- EnableExperimentalAllowlistOptimizations bool
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type viperRuleAllowlist struct {
|
|
type viperRuleAllowlist struct {
|
|
@@ -261,14 +255,13 @@ func (vc *ViperConfig) parseAllowlist(a *viperRuleAllowlist) (*Allowlist, error)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
allowlist := &Allowlist{
|
|
allowlist := &Allowlist{
|
|
|
- Description: a.Description,
|
|
|
|
|
- MatchCondition: matchCondition,
|
|
|
|
|
- Commits: a.Commits,
|
|
|
|
|
- Paths: allowlistPaths,
|
|
|
|
|
- RegexTarget: regexTarget,
|
|
|
|
|
- Regexes: allowlistRegexes,
|
|
|
|
|
- StopWords: a.StopWords,
|
|
|
|
|
- EnableExperimentalOptimizations: vc.EnableExperimentalAllowlistOptimizations,
|
|
|
|
|
|
|
+ Description: a.Description,
|
|
|
|
|
+ MatchCondition: matchCondition,
|
|
|
|
|
+ Commits: a.Commits,
|
|
|
|
|
+ Paths: allowlistPaths,
|
|
|
|
|
+ RegexTarget: regexTarget,
|
|
|
|
|
+ Regexes: allowlistRegexes,
|
|
|
|
|
+ StopWords: a.StopWords,
|
|
|
}
|
|
}
|
|
|
if err := allowlist.Validate(); err != nil {
|
|
if err := allowlist.Validate(); err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
@@ -292,9 +285,7 @@ func (c *Config) extendDefault(parent *ViperConfig) error {
|
|
|
if err := viper.ReadConfig(strings.NewReader(DefaultConfig)); err != nil {
|
|
if err := viper.ReadConfig(strings.NewReader(DefaultConfig)); err != nil {
|
|
|
return fmt.Errorf("failed to load extended default config, err: %w", err)
|
|
return fmt.Errorf("failed to load extended default config, err: %w", err)
|
|
|
}
|
|
}
|
|
|
- defaultViperConfig := ViperConfig{
|
|
|
|
|
- EnableExperimentalAllowlistOptimizations: parent.EnableExperimentalAllowlistOptimizations,
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ defaultViperConfig := ViperConfig{}
|
|
|
if err := viper.Unmarshal(&defaultViperConfig); err != nil {
|
|
if err := viper.Unmarshal(&defaultViperConfig); err != nil {
|
|
|
return fmt.Errorf("failed to load extended default config, err: %w", err)
|
|
return fmt.Errorf("failed to load extended default config, err: %w", err)
|
|
|
}
|
|
}
|
|
@@ -314,9 +305,7 @@ func (c *Config) extendPath(parent *ViperConfig) error {
|
|
|
if err := viper.ReadInConfig(); err != nil {
|
|
if err := viper.ReadInConfig(); err != nil {
|
|
|
return fmt.Errorf("failed to load extended config, err: %w", err)
|
|
return fmt.Errorf("failed to load extended config, err: %w", err)
|
|
|
}
|
|
}
|
|
|
- extensionViperConfig := ViperConfig{
|
|
|
|
|
- EnableExperimentalAllowlistOptimizations: parent.EnableExperimentalAllowlistOptimizations,
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ extensionViperConfig := ViperConfig{}
|
|
|
if err := viper.Unmarshal(&extensionViperConfig); err != nil {
|
|
if err := viper.Unmarshal(&extensionViperConfig); err != nil {
|
|
|
return fmt.Errorf("failed to load extended config, err: %w", err)
|
|
return fmt.Errorf("failed to load extended config, err: %w", err)
|
|
|
}
|
|
}
|