Skip to content

Commit

Permalink
always set the transaction in the current request (#2682)
Browse files Browse the repository at this point in the history
  • Loading branch information
blotus authored Dec 22, 2023
1 parent a62e28f commit b6f272d
Showing 1 changed file with 6 additions and 5 deletions.
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) Init(datadir string) error {
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 @@ func (r *AppsecRunner) processRequest(tx appsec.ExtendedTransaction, request *ap
//FIXME: should we abort here ?
}

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

for k, v := range request.Args {
for _, vv := range v {
Expand Down Expand Up @@ -194,6 +193,7 @@ func (r *AppsecRunner) processRequest(tx appsec.ExtendedTransaction, request *ap
func (r *AppsecRunner) ProcessInBandRules(request *appsec.ParsedRequest) error {
tx := appsec.NewExtendedTransaction(r.AppsecInbandEngine, request.UUID)
r.AppsecRuntime.InBandTx = tx
request.Tx = tx
if len(r.AppsecRuntime.InBandRules) == 0 {
return nil
}
Expand All @@ -202,11 +202,12 @@ func (r *AppsecRunner) ProcessInBandRules(request *appsec.ParsedRequest) error {
}

func (r *AppsecRunner) ProcessOutOfBandRules(request *appsec.ParsedRequest) error {
tx := appsec.NewExtendedTransaction(r.AppsecOutbandEngine, request.UUID)
r.AppsecRuntime.OutOfBandTx = tx
request.Tx = tx
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 @@ func (r *AppsecRunner) handleRequest(request *appsec.ParsedRequest) {

// 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())
if request.Tx.IsInterrupted() {
r.handleOutBandInterrupt(request)
}
Expand Down

0 comments on commit b6f272d

Please sign in to comment.