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

always set the transaction in the current request #2682

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions pkg/acquisition/modules/appsec/appsec_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
func (r *AppsecRunner) processRequest(tx appsec.ExtendedTransaction, request *appsec.ParsedRequest) error {
var in *corazatypes.Interruption
var err error
request.Tx = tx

if request.Tx.IsRuleEngineOff() {
r.logger.Debugf("rule engine is off, skipping")
Expand All @@ -129,7 +128,7 @@
//FIXME: should we abort here ?
}

request.Tx.Tx.ProcessConnection(request.RemoteAddr, 0, "", 0)
request.Tx.ProcessConnection(request.RemoteAddr, 0, "", 0)

Check warning on line 131 in pkg/acquisition/modules/appsec/appsec_runner.go

View check run for this annotation

Codecov / codecov/patch

pkg/acquisition/modules/appsec/appsec_runner.go#L131

Added line #L131 was not covered by tests

for k, v := range request.Args {
for _, vv := range v {
Expand Down Expand Up @@ -194,6 +193,7 @@
func (r *AppsecRunner) ProcessInBandRules(request *appsec.ParsedRequest) error {
tx := appsec.NewExtendedTransaction(r.AppsecInbandEngine, request.UUID)
r.AppsecRuntime.InBandTx = tx
request.Tx = tx

Check warning on line 196 in pkg/acquisition/modules/appsec/appsec_runner.go

View check run for this annotation

Codecov / codecov/patch

pkg/acquisition/modules/appsec/appsec_runner.go#L196

Added line #L196 was not covered by tests
if len(r.AppsecRuntime.InBandRules) == 0 {
return nil
}
Expand All @@ -202,11 +202,12 @@
}

func (r *AppsecRunner) ProcessOutOfBandRules(request *appsec.ParsedRequest) error {
tx := appsec.NewExtendedTransaction(r.AppsecOutbandEngine, request.UUID)
r.AppsecRuntime.OutOfBandTx = tx
request.Tx = tx

Check warning on line 207 in pkg/acquisition/modules/appsec/appsec_runner.go

View check run for this annotation

Codecov / codecov/patch

pkg/acquisition/modules/appsec/appsec_runner.go#L205-L207

Added lines #L205 - L207 were not covered by tests
if len(r.AppsecRuntime.OutOfBandRules) == 0 {
return nil
}
tx := appsec.NewExtendedTransaction(r.AppsecOutbandEngine, request.UUID)
r.AppsecRuntime.OutOfBandTx = tx
err := r.processRequest(tx, request)
return err
}
Expand Down Expand Up @@ -348,7 +349,7 @@

// time spent to process out of band rules
outOfBandParsingElapsed := time.Since(startOutOfBandParsing)
AppsecOutbandParsingHistogram.With(prometheus.Labels{"source": request.RemoteAddrNormalized}).Observe(outOfBandParsingElapsed.Seconds())
AppsecOutbandParsingHistogram.With(prometheus.Labels{"source": request.RemoteAddrNormalized, "appsec_engine": request.AppsecEngine}).Observe(outOfBandParsingElapsed.Seconds())

Check warning on line 352 in pkg/acquisition/modules/appsec/appsec_runner.go

View check run for this annotation

Codecov / codecov/patch

pkg/acquisition/modules/appsec/appsec_runner.go#L352

Added line #L352 was not covered by tests
if request.Tx.IsInterrupted() {
r.handleOutBandInterrupt(request)
}
Expand Down