Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions utils/getconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,20 @@ func validateConfigProfile(configProfile *services.ConfigProfile) error {
return errors.New("received a nil config profile")
}

if len(configProfile.Modules) != 1 {
return fmt.Errorf("%s config profile returned with %d modules. A profile must have exactly 1 module", configProfile.ProfileName, len(configProfile.Modules))
if len(configProfile.Modules) == 0 {
log.Warn(fmt.Sprintf("%s config profile returned with 0 modules. Using default module", configProfile.ProfileName))
configProfile.Modules = createDefaultConfig()
}
if len(configProfile.Modules) > 1 {
log.Warn(fmt.Sprintf("%s config profile returned with %d modules. Only the first module will be used", configProfile.ProfileName, len(configProfile.Modules)))
Comment on lines +545 to +546

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit tricky, I don't think its a good Idea to use only one

}

if configProfile.Modules[0].PathFromRoot != "." {
return fmt.Errorf("the module in the config profile should be associated with the root of the repository. Expected pathFromRoot to be '.' but received '%s'", configProfile.Modules[0].PathFromRoot)
}
return nil
}

func createDefaultConfig() []services.Module {
return []services.Module{{PathFromRoot: ".", ScanConfig: services.ScanConfig{ScaScannerConfig: services.ScaScannerConfig{EnableScaScan: true}}}}
}
Loading