From e0bd4dc9280b1e19a0a068d1ee5f0177b8ff451d Mon Sep 17 00:00:00 2001 From: alteredCoder Date: Thu, 24 Aug 2023 12:11:44 +0200 Subject: [PATCH] fix linter --- pkg/acquisition/modules/waf/waf.go | 8 +++----- pkg/waf/request.go | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/acquisition/modules/waf/waf.go b/pkg/acquisition/modules/waf/waf.go index ec247f68a..341e2e5c8 100644 --- a/pkg/acquisition/modules/waf/waf.go +++ b/pkg/acquisition/modules/waf/waf.go @@ -61,8 +61,6 @@ type WafSource struct { outChan chan types.Event InChan chan waf.ParsedRequest - inBandWaf coraza.WAF - outOfBandWaf coraza.WAF RulesCollections []*waf.WafRulesCollection WafRunners []WafRunner @@ -464,7 +462,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error { switch t := res.(type) { case bool: - if t == false { + if !t { log.Infof("filter didnt match") continue } @@ -518,7 +516,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error { switch t := res.(type) { case bool: - if t == false { + if !t { continue } default: @@ -569,6 +567,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error { // Process outBand outBandTx := r.outOfBandWaf.NewTransactionWithID(request.UUID) expTx = outBandTx.(experimental.FullTransaction) + in, expTx, err = r.processReqWithEngine(expTx, request, OutOfBand) if err != nil { //things went south r.logger.Errorf("Error while processing request : %s", err) @@ -655,5 +654,4 @@ func (w *WafSource) wafHandler(rw http.ResponseWriter, r *http.Request) { rw.Write(body) } - return } diff --git a/pkg/waf/request.go b/pkg/waf/request.go index 07da78058..bed7a6ef9 100644 --- a/pkg/waf/request.go +++ b/pkg/waf/request.go @@ -2,7 +2,7 @@ package waf import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" @@ -78,12 +78,11 @@ type ParsedRequest struct { } func NewParsedRequestFromRequest(r *http.Request) (ParsedRequest, error) { - var body []byte var err error + body := make([]byte, 0) if r.Body != nil { - body = make([]byte, 0) - body, err = ioutil.ReadAll(r.Body) + body, err = io.ReadAll(r.Body) if err != nil { return ParsedRequest{}, fmt.Errorf("unable to read body: %s", err) }