From 8999154f766e2666df60d5826dd1d9747430792b Mon Sep 17 00:00:00 2001 From: Sebastien Blot Date: Tue, 28 Nov 2023 11:02:29 +0100 Subject: [PATCH] up --- pkg/acquisition/modules/waap/waap.go | 4 +++- pkg/acquisition/modules/waap/waap_runner.go | 4 ++++ pkg/waf/waap.go | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/acquisition/modules/waap/waap.go b/pkg/acquisition/modules/waap/waap.go index a478c2779..a35d06175 100644 --- a/pkg/acquisition/modules/waap/waap.go +++ b/pkg/acquisition/modules/waap/waap.go @@ -364,7 +364,9 @@ func (w *WaapSource) waapHandler(rw http.ResponseWriter, r *http.Request) { WafBlockCounter.With(prometheus.Labels{"source": parsedRequest.RemoteAddrNormalized, "waap_engine": parsedRequest.WaapEngine}).Inc() } - waapResponse := w.WaapRuntime.GenerateResponse(response.InBandInterrupt) + w.logger.Infof("Response: %+v", response) + + waapResponse := w.WaapRuntime.GenerateResponse(response) rw.WriteHeader(waapResponse.HTTPStatus) body, err := json.Marshal(BodyResponse{Action: waapResponse.Action}) diff --git a/pkg/acquisition/modules/waap/waap_runner.go b/pkg/acquisition/modules/waap/waap_runner.go index 9a07f0966..93e054160 100644 --- a/pkg/acquisition/modules/waap/waap_runner.go +++ b/pkg/acquisition/modules/waap/waap_runner.go @@ -213,6 +213,7 @@ func (r *WaapRunner) Run(t *tomb.Tomb) error { continue } } + elapsed := time.Since(startParsing) WafInbandParsingHistogram.With(prometheus.Labels{"source": request.RemoteAddr}).Observe(elapsed.Seconds()) @@ -220,6 +221,9 @@ func (r *WaapRunner) Run(t *tomb.Tomb) error { //@tko : this should move in the WaapRuntimeConfig as it knows what to do with the interruption and the expected remediation // send back the result to the HTTP handler for the InBand part + + r.logger.Infof("Response: %+v", r.WaapRuntime.Response) + request.ResponseChannel <- r.WaapRuntime.Response request.IsInBand = false diff --git a/pkg/waf/waap.go b/pkg/waf/waap.go index c72076db3..54d10b67c 100644 --- a/pkg/waf/waap.go +++ b/pkg/waf/waap.go @@ -468,21 +468,21 @@ type BodyResponse struct { HTTPStatus int `json:"http_status"` } -func (w *WaapRuntimeConfig) GenerateResponse(interrupted bool) BodyResponse { +func (w *WaapRuntimeConfig) GenerateResponse(response WaapTempResponse) BodyResponse { resp := BodyResponse{} //if there is no interrupt, we should allow with default code - if !interrupted { + if !response.InBandInterrupt { resp.Action = w.Config.DefaultPassAction resp.HTTPStatus = w.Config.PassedHTTPCode return resp } - resp.Action = w.Response.Action + resp.Action = response.Action if resp.Action == "" { resp.Action = w.Config.DefaultRemediation } w.Logger.Debugf("action is %s", resp.Action) - resp.HTTPStatus = w.Response.HTTPResponseCode + resp.HTTPStatus = response.HTTPResponseCode if resp.HTTPStatus == 0 { resp.HTTPStatus = w.Config.BlockedHTTPCode }