Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix middleware duplicated creation of transactions #1196

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions http/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@
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 {

Check failure on line 105 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: newTX

Check failure on line 105 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: newTX

Check failure on line 105 in http/middleware.go

View workflow job for this annotation

GitHub Actions / lint

undefined: newTX

Check failure on line 105 in http/middleware.go

View workflow job for this annotation

GitHub Actions / lint

undefined: newTX

Check failure on line 105 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: newTX

Check failure on line 105 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: newTX
return ctxwaf.NewTransactionWithOptions(experimental.Options{
Context: r.Context(),
})
}
} else {
newTX := func(*http.Request) types.Transaction {

Check failure on line 111 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

newTX declared and not used

Check failure on line 111 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

newTX declared and not used

Check failure on line 111 in http/middleware.go

View workflow job for this annotation

GitHub Actions / lint

newTX declared and not used

Check failure on line 111 in http/middleware.go

View workflow job for this annotation

GitHub Actions / lint

newTX declared and not used

Check failure on line 111 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

declared and not used: newTX

Check failure on line 111 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

declared and not used: newTX
return waf.NewTransaction()
}
}

fn := func(w http.ResponseWriter, r *http.Request) {
tx := newTX(r)

Check failure on line 117 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: newTX

Check failure on line 117 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: newTX

Check failure on line 117 in http/middleware.go

View workflow job for this annotation

GitHub Actions / lint

undefined: newTX (typecheck)

Check failure on line 117 in http/middleware.go

View workflow job for this annotation

GitHub Actions / lint

undefined: newTX) (typecheck)

Check failure on line 117 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: newTX

Check failure on line 117 in http/middleware.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: newTX
defer func() {
// We run phase 5 rules and create audit logs (if enabled)
tx.ProcessLogging()
Expand Down
Loading