v7.x Update - Add ability to append repo configurations, and user supplied configurations to the specified or default configuration (#487)

* Update merge configuration changes for  Gitleaks 7.x

* Change merge to append, and did some clean up
This commit is contained in:
eddie-northcutt-wfp0 authored and GitHub committed 2021-03-05 15:09:10 -05:00
1 parent a8dbc7f107
commit a10ae91ba7
10 files changed
+263 -47

No files matched your search

+23 -2
View File
@@ -45,6 +45,13 @@ func NewScanner(opts options.Options, cfg config.Config) (Scanner, error) {
return nil, err
}
if st == typeDirScanner {
if opts.AdditionalConfig != "" {
additionalCfg, err := config.LoadAdditionalConfig(opts.AdditionalConfig)
if err != nil {
return nil, err
}
cfg = cfg.AppendConfig(additionalCfg)
}
return NewParentScanner(opts, cfg), nil
}
@@ -56,12 +63,26 @@ func NewScanner(opts options.Options, cfg config.Config) (Scanner, error) {
}
}
// load up alternative config if possible, if not use manager's config
// load up alternative config if possible, if not use default/specified config. Will append if AppendRepoConfig is true
if opts.RepoConfigPath != "" && !opts.NoGit {
cfg, err = config.LoadRepoConfig(repo, opts.RepoConfigPath)
repoCfg, err := config.LoadRepoConfig(repo, opts.RepoConfigPath)
if err != nil {
return nil, err
}
if opts.AppendRepoConfig {
cfg = cfg.AppendConfig(repoCfg)
} else {
cfg = repoCfg
}
}
// append additional config with the rest of the config
if opts.AdditionalConfig != "" {
additionalCfg, err := config.LoadAdditionalConfig(opts.AdditionalConfig)
if err != nil {
return nil, err
}
cfg = cfg.AppendConfig(additionalCfg)
}
switch st {