do not error if no waap rules are present
This commit is contained in:
parent
4a265ca4af
commit
2d01e4680f
|
@ -827,8 +827,8 @@ func (t *HubTestItem) Run() error {
|
||||||
return fmt.Errorf("unable to create folder '%s': %+v", t.RuntimePath, err)
|
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 it's a waap rule test, we need acquis and waap profile
|
||||||
if t.Config.NucleiTemplate != "" {
|
if len(t.Config.WaapRules) > 0 {
|
||||||
// copy template acquis file to runtime folder
|
// copy template acquis file to runtime folder
|
||||||
log.Infof("copying %s to %s", t.TemplateAcquisPath, t.RuntimeAcquisFilePath)
|
log.Infof("copying %s to %s", t.TemplateAcquisPath, t.RuntimeAcquisFilePath)
|
||||||
if err = Copy(t.TemplateAcquisPath, t.RuntimeAcquisFilePath); err != nil {
|
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 {
|
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)
|
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
|
// install the hub in the runtime folder
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package waf
|
package waf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
||||||
|
@ -53,7 +52,7 @@ func LoadWaapRules(hubInstance *cwhub.Hub) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(waapRules) == 0 {
|
if len(waapRules) == 0 {
|
||||||
return fmt.Errorf("no waap rules found in hub")
|
log.Debugf("No waap rules found")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue