do not error if no waap rules are present

This commit is contained in:
bui 2023-11-20 14:25:33 +01:00
parent 4a265ca4af
commit 2d01e4680f
2 changed files with 7 additions and 4 deletions

View file

@ -827,8 +827,8 @@ func (t *HubTestItem) Run() error {
return fmt.Errorf("unable to create folder '%s': %+v", t.RuntimePath, err)
}
// copy the waap-config file and acquis *only* if nuclei template is set -> it means we're testing waap
if t.Config.NucleiTemplate != "" {
//if it's a waap rule test, we need acquis and waap profile
if len(t.Config.WaapRules) > 0 {
// copy template acquis file to runtime folder
log.Infof("copying %s to %s", t.TemplateAcquisPath, t.RuntimeAcquisFilePath)
if err = Copy(t.TemplateAcquisPath, t.RuntimeAcquisFilePath); err != nil {
@ -840,6 +840,10 @@ func (t *HubTestItem) Run() error {
if err = Copy(t.TemplateWaapProfilePath, filepath.Join(t.RuntimePath, "waap-configs", "config.yaml")); err != nil {
return fmt.Errorf("unable to copy '%s' to '%s': %v", t.TemplateWaapProfilePath, filepath.Join(t.RuntimePath, "waap-configs", "config.yaml"), err)
}
} else { //otherwise we drop a blank acquis file
if err = os.WriteFile(t.RuntimeAcquisFilePath, []byte(""), os.ModePerm); err != nil {
return fmt.Errorf("unable to write blank acquis file '%s': %s", t.RuntimeAcquisFilePath, err)
}
}
// install the hub in the runtime folder

View file

@ -1,7 +1,6 @@
package waf
import (
"fmt"
"os"
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
@ -53,7 +52,7 @@ func LoadWaapRules(hubInstance *cwhub.Hub) error {
}
if len(waapRules) == 0 {
return fmt.Errorf("no waap rules found in hub")
log.Debugf("No waap rules found")
}
return nil
}