Skip to content

Commit

Permalink
Fix crash if plugin config is broken (crowdsecurity#964)
Browse files Browse the repository at this point in the history
Signed-off-by: Shivam Sandbhor <[email protected]>
  • Loading branch information
sbs2001 authored Sep 10, 2021
1 parent dd41c30 commit cca76da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/csplugin/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (pb *PluginBroker) loadConfig(path string) error {

pluginConfigs, err := parsePluginConfigFile(configFilePath)
if err != nil {
return errors.Wrapf(err, "got error while parsing %s", configFilePath)
return err
}
for _, pluginConfig := range pluginConfigs {
if !pb.profilesContainPlugin(pluginConfig.Name) {
Expand Down Expand Up @@ -309,15 +309,15 @@ func parsePluginConfigFile(path string) ([]PluginConfig, error) {
return parsedConfigs, errors.Wrapf(err, "while opening %s", path)
}
dec := yaml.NewDecoder(yamlFile)
dec.SetStrict(true)
for {
pc := PluginConfig{}
err = dec.Decode(&pc)
if err != nil {
if err == io.EOF {
break
}
log.Errorf("while decoding %s got error %s", path, err.Error())
continue
return []PluginConfig{}, fmt.Errorf("while decoding %s got error %s", path, err.Error())
}
parsedConfigs = append(parsedConfigs, pc)
}
Expand Down

0 comments on commit cca76da

Please sign in to comment.