Skip to content

Commit

Permalink
[K9VULN-3784] Use root path to properly find config file
Browse files Browse the repository at this point in the history
  • Loading branch information
bahar-shah committed Feb 26, 2025
1 parent 161d000 commit 73bac20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func ExecuteKICSScan(inputPaths []string, outputPath string, sciInfo model.SCIInfo) (scan.ScanMetadata, string) {
params := scan.GetDefaultParameters()
params := scan.GetDefaultParameters(outputPath)
params.Path = inputPaths
params.OutputPath = outputPath
params.SCIInfo = sciInfo
Expand Down
4 changes: 2 additions & 2 deletions pkg/scan/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ type Client struct {
ProBarBuilder *progress.PbBuilder
}

func GetDefaultParameters() *Parameters {
func GetDefaultParameters(rootPath string) *Parameters {

// check for config file and load in relevant params if present
configParams, err := initializeConfig()
configParams, err := initializeConfig(rootPath)
if err != nil {
log.Err(err).Msgf("failed to initialize config %v", err)
return nil
Expand Down
5 changes: 3 additions & 2 deletions pkg/scan/pre_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func setupConfigFile() (bool, error) {
return false, nil
}

func initializeConfig() (ConfigParameters, error) {
func initializeConfig(rootPath string) (ConfigParameters, error) {
log.Debug().Msg("console.initializeConfig()")

configParams := ConfigParameters{}
Expand All @@ -46,8 +46,9 @@ func initializeConfig() (ConfigParameters, error) {
if exit {
return configParams, nil
}
configPath := filepath.Join(rootPath, constants.DefaultConfigFilename)

base := filepath.Base(constants.DefaultConfigFilename)
base := filepath.Base(configPath)
v.SetConfigName(base)
v.AddConfigPath(filepath.Dir(base))
ext, err := consoleHelpers.FileAnalyzer(base)
Expand Down

0 comments on commit 73bac20

Please sign in to comment.