From d9dedb8349b63b59f935b58e1c418baad73fef7f Mon Sep 17 00:00:00 2001 From: Juan Pablo Tosso Date: Tue, 5 Nov 2024 15:22:15 +0000 Subject: [PATCH 1/2] Fix middleware duplicated creation of transactions --- http/middleware.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http/middleware.go b/http/middleware.go index c1e3f50bb..138c7f75a 100644 --- a/http/middleware.go +++ b/http/middleware.go @@ -101,16 +101,16 @@ func WrapHandler(waf coraza.WAF, h http.Handler) http.Handler { return h } - newTX := func(*http.Request) types.Transaction { - return waf.NewTransaction() - } - if ctxwaf, ok := waf.(experimental.WAFWithOptions); ok { newTX = func(r *http.Request) types.Transaction { return ctxwaf.NewTransactionWithOptions(experimental.Options{ Context: r.Context(), }) } + } else { + newTX := func(*http.Request) types.Transaction { + return waf.NewTransaction() + } } fn := func(w http.ResponseWriter, r *http.Request) { From 8a5604e41a79baa0b27ec70eed3f80dc5d50009c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:41:50 +0000 Subject: [PATCH 2/2] Revert broken middleware change - restore correct newTX declaration pattern Agent-Logs-Url: https://github.com/corazawaf/coraza/sessions/b8d0f0b7-705f-4a49-a5fb-b1c72ba544ae Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com> --- http/middleware.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http/middleware.go b/http/middleware.go index 138c7f75a..c1e3f50bb 100644 --- a/http/middleware.go +++ b/http/middleware.go @@ -101,16 +101,16 @@ func WrapHandler(waf coraza.WAF, h http.Handler) http.Handler { return h } + newTX := func(*http.Request) types.Transaction { + return waf.NewTransaction() + } + if ctxwaf, ok := waf.(experimental.WAFWithOptions); ok { newTX = func(r *http.Request) types.Transaction { return ctxwaf.NewTransactionWithOptions(experimental.Options{ Context: r.Context(), }) } - } else { - newTX := func(*http.Request) types.Transaction { - return waf.NewTransaction() - } } fn := func(w http.ResponseWriter, r *http.Request) {