fix linter

This commit is contained in:
alteredCoder 2023-08-24 12:11:44 +02:00
parent 4846701ed5
commit e0bd4dc928
2 changed files with 6 additions and 9 deletions

View file

@ -61,8 +61,6 @@ type WafSource struct {
outChan chan types.Event outChan chan types.Event
InChan chan waf.ParsedRequest InChan chan waf.ParsedRequest
inBandWaf coraza.WAF
outOfBandWaf coraza.WAF
RulesCollections []*waf.WafRulesCollection RulesCollections []*waf.WafRulesCollection
WafRunners []WafRunner WafRunners []WafRunner
@ -464,7 +462,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error {
switch t := res.(type) { switch t := res.(type) {
case bool: case bool:
if t == false { if !t {
log.Infof("filter didnt match") log.Infof("filter didnt match")
continue continue
} }
@ -518,7 +516,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error {
switch t := res.(type) { switch t := res.(type) {
case bool: case bool:
if t == false { if !t {
continue continue
} }
default: default:
@ -569,6 +567,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error {
// Process outBand // Process outBand
outBandTx := r.outOfBandWaf.NewTransactionWithID(request.UUID) outBandTx := r.outOfBandWaf.NewTransactionWithID(request.UUID)
expTx = outBandTx.(experimental.FullTransaction) expTx = outBandTx.(experimental.FullTransaction)
in, expTx, err = r.processReqWithEngine(expTx, request, OutOfBand) in, expTx, err = r.processReqWithEngine(expTx, request, OutOfBand)
if err != nil { //things went south if err != nil { //things went south
r.logger.Errorf("Error while processing request : %s", err) 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) rw.Write(body)
} }
return
} }

View file

@ -2,7 +2,7 @@ package waf
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
@ -78,12 +78,11 @@ type ParsedRequest struct {
} }
func NewParsedRequestFromRequest(r *http.Request) (ParsedRequest, error) { func NewParsedRequestFromRequest(r *http.Request) (ParsedRequest, error) {
var body []byte
var err error var err error
body := make([]byte, 0)
if r.Body != nil { if r.Body != nil {
body = make([]byte, 0) body, err = io.ReadAll(r.Body)
body, err = ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
return ParsedRequest{}, fmt.Errorf("unable to read body: %s", err) return ParsedRequest{}, fmt.Errorf("unable to read body: %s", err)
} }