diff --git a/pkg/acquisition/modules/waf/waf.go b/pkg/acquisition/modules/waf/waf.go index c09312119..0591d9b44 100644 --- a/pkg/acquisition/modules/waf/waf.go +++ b/pkg/acquisition/modules/waf/waf.go @@ -152,17 +152,11 @@ func (w *WafSource) Configure(yamlConfig []byte, logger *log.Entry) error { ruleLoader := waf.NewWafRuleLoader() -<<<<<<< HEAD rulesCollections, err := ruleLoader.LoadWafRules() - -======= - err = crowdsecWafConfig.LoadWafRules() ->>>>>>> 0c10c8f0 (update waf) if err != nil { return fmt.Errorf("cannot load WAF rules: %w", err) } -<<<<<<< HEAD var inBandRules string var outOfBandRules string @@ -181,22 +175,14 @@ func (w *WafSource) Configure(yamlConfig []byte, logger *log.Entry) error { //w.logger.Infof("Loading rules %+v", inBandRules) fs := os.DirFS(ruleLoader.Datadir) -======= // always have at least one waf routine if w.config.WafRoutines == 0 { w.config.WafRoutines = 1 } - fs := os.DirFS(crowdsecWafConfig.Datadir) w.InChan = make(chan ParsedRequest) w.WafRunners = make([]WafRunner, w.config.WafRoutines) for nbRoutine := 0; nbRoutine < w.config.WafRoutines; nbRoutine++ { - var inBandRules string - for _, rule := range crowdsecWafConfig.InbandRules { ->>>>>>> 0c10c8f0 (update waf) - - inBandRules += rule.String() + "\n" - } w.logger.Infof("Loading %d in-band rules", len(strings.Split(inBandRules, "\n"))) //in-band waf : kill on sight @@ -209,13 +195,6 @@ func (w *WafSource) Configure(yamlConfig []byte, logger *log.Entry) error { if err != nil { return errors.Wrap(err, "Cannot create WAF") } - w.inBandWaf = inbandwaf - - var outOfBandRules string - for _, rule := range crowdsecWafConfig.OutOfBandRules { - outOfBandRules += rule.String() + "\n" - } - w.logger.Infof("Loading %d out-of-band rules", len(strings.Split(outOfBandRules, "\n"))) //out-of-band waf : log only outofbandwaf, err := coraza.NewWAF( @@ -236,26 +215,13 @@ func (w *WafSource) Configure(yamlConfig []byte, logger *log.Entry) error { } w.WafRunners[nbRoutine] = runner } -<<<<<<< HEAD - w.inBandWaf = inbandwaf w.logger.Infof("Loading %d out-of-band rules", len(strings.Split(outOfBandRules, "\n"))) - //out-of-band waf : log only - outofbandwaf, err := coraza.NewWAF( - coraza.NewWAFConfig(). - WithErrorCallback(logError). - WithDirectives(outOfBandRules).WithRootFS(fs), - ) - if err != nil { return errors.Wrap(err, "Cannot create WAF") } - w.outOfBandWaf = outofbandwaf -======= - //log.Printf("IB -> %s", spew.Sdump(w.inBandWaf)) //We donĀ“t use the wrapper provided by coraza because we want to fully control what happens when a rule match to send the information in crowdsec ->>>>>>> 0c10c8f0 (update waf) w.mux.HandleFunc(w.config.Path, w.wafHandler) return nil @@ -374,8 +340,6 @@ func processReqWithEngine(waf coraza.WAF, r ParsedRequest, uuid string, wafType tx.Close() }() - log.Infof("Processing request with %s WAF", wafType) - //this method is not exported by coraza, so we have to do it ourselves. //ideally, this would be dealt with by expr code, and we provide helpers to manipulate the transaction object?\ //var txx experimental.FullTransaction diff --git a/pkg/waf/waf.go b/pkg/waf/waf.go index d004213b7..0c61d2447 100644 --- a/pkg/waf/waf.go +++ b/pkg/waf/waf.go @@ -43,8 +43,6 @@ type WafConfig struct { OnLoad []Hook `yaml:"on_load"` PreEval []Hook `yaml:"pre_eval"` OnMatch []Hook `yaml:"on_match"` -<<<<<<< HEAD -======= CompiledOnLoad []CompiledHook `yaml:"-"` CompiledPreEval []CompiledHook `yaml:"-"` @@ -52,7 +50,6 @@ type WafConfig struct { MergedRules []string `yaml:"-"` OutOfBand bool `yaml:"outofband"` ->>>>>>> 0c10c8f0 (update waf) } type WafRuleLoader struct {