This commit is contained in:
Sebastien Blot 2023-11-08 20:37:05 +01:00
parent 1154ada2df
commit 927310a439
No known key found for this signature in database
GPG key ID: DFC2902F40449F6A
2 changed files with 14 additions and 18 deletions

View file

@ -129,33 +129,28 @@ func (w *WaapSource) Configure(yamlConfig []byte, logger *log.Entry) error {
}
w.InChan = make(chan waf.ParsedRequest)
waapCfg := waf.WaapConfig{Logger: w.logger.WithField("component", "waap_config")}
//let's load the associated waap_config:
if w.config.WaapConfigPath != "" {
waapCfg := waf.WaapConfig{Logger: w.logger.WithField("component", "waap_config")}
if w.config.WaapConfigPath != "" {
err := waapCfg.LoadByPath(w.config.WaapConfigPath)
if err != nil {
return fmt.Errorf("unable to load waap_config : %s", err)
}
} else if w.config.WaapConfig != "" {
err := waapCfg.Load(w.config.WaapConfig)
if err != nil {
return fmt.Errorf("unable to load waap_config : %s", err)
}
} else {
return fmt.Errorf("no waap_config provided")
}
w.WaapRuntime, err = waapCfg.Build()
err := waapCfg.LoadByPath(w.config.WaapConfigPath)
if err != nil {
return fmt.Errorf("unable to build waap_config : %s", err)
return fmt.Errorf("unable to load waap_config : %s", err)
}
} else if w.config.WaapConfig != "" {
return fmt.Errorf("resolution of waap_config not implemented yet")
err := waapCfg.Load(w.config.WaapConfig)
if err != nil {
return fmt.Errorf("unable to load waap_config : %s", err)
}
} else {
return fmt.Errorf("no waap_config provided")
}
w.WaapRuntime, err = waapCfg.Build()
if err != nil {
return fmt.Errorf("unable to build waap_config : %s", err)
}
err = w.WaapRuntime.ProcessOnLoadRules()
if err != nil {

View file

@ -168,9 +168,10 @@ func (wc *WaapConfig) Load(configName string) error {
if err != nil {
return fmt.Errorf("unable to load waap-config %s : %s", hubWaapConfigItem.LocalPath, err)
}
return nil
}
return nil
return fmt.Errorf("no waap-config found for %s", configName)
}
func (wc *WaapConfig) Build() (*WaapRuntimeConfig, error) {