mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
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:
1 parent
a8dbc7f107
commit
a10ae91ba7
10 files changed
+263
-47
No files matched your search
+23
-2
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user