Skip to content

Commit

Permalink
Update root path for config file lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
bahar-shah committed Feb 26, 2025
1 parent e7c0d03 commit 2e9e005
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/scan/pre_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ type ConfigParameters struct {
ExcludeSeverities []string
}

func setupConfigFile() (bool, error) {
_, err := os.Stat(constants.DefaultConfigFilename)
func setupConfigFile(rootPath string) (bool, error) {
configPath := filepath.Join(rootPath, constants.DefaultConfigFilename)
_, err := os.Stat(configPath)
if err != nil {
if os.IsNotExist(err) {
log.Info().Msgf("Config file not found at %s", configPath)
return true, nil
}
log.Info().Msgf("Error reading config file at %s", configPath)
return true, err
}

log.Info().Msgf("Config file found at %s", configPath)
return false, nil
}

Expand All @@ -39,7 +43,7 @@ func initializeConfig(rootPath string) (ConfigParameters, error) {
v.SetEnvPrefix("KICS")
v.AutomaticEnv()

exit, err := setupConfigFile()
exit, err := setupConfigFile(rootPath)
if err != nil {
return configParams, err
}
Expand Down

0 comments on commit 2e9e005

Please sign in to comment.