check for interruption and ignore empty messages
This commit is contained in:
parent
877d4fc32d
commit
3fe6e3be14
|
@ -18,6 +18,9 @@ func TxToEvents(r ParsedRequest, kind string) ([]types.Event, error) {
|
||||||
}
|
}
|
||||||
for _, rule := range r.Tx.MatchedRules() {
|
for _, rule := range r.Tx.MatchedRules() {
|
||||||
//log.Printf("rule %d", idx)
|
//log.Printf("rule %d", idx)
|
||||||
|
if rule.Message() == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
evt, err := RuleMatchToEvent(rule, r.Tx, r, kind)
|
evt, err := RuleMatchToEvent(rule, r.Tx, r, kind)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Cannot convert rule match to event")
|
return nil, errors.Wrap(err, "Cannot convert rule match to event")
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/waf"
|
"github.com/crowdsecurity/crowdsec/pkg/waf"
|
||||||
"github.com/crowdsecurity/go-cs-lib/pkg/trace"
|
"github.com/crowdsecurity/go-cs-lib/pkg/trace"
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
@ -373,9 +372,9 @@ func processReqWithEngine(waf coraza.WAF, r ParsedRequest, uuid string, wafType
|
||||||
//spew.Dump(in)
|
//spew.Dump(in)
|
||||||
//spew.Dump(tx.MatchedRules())
|
//spew.Dump(tx.MatchedRules())
|
||||||
|
|
||||||
for _, rule := range tx.MatchedRules() {
|
/*for _, rule := range tx.MatchedRules() {
|
||||||
spew.Dump(rule.Rule())
|
spew.Dump(rule.Rule())
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//if we're inband, we should stop here, but for outofband go to the end
|
//if we're inband, we should stop here, but for outofband go to the end
|
||||||
if in != nil && wafType == InBand {
|
if in != nil && wafType == InBand {
|
||||||
|
@ -432,6 +431,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error {
|
||||||
}
|
}
|
||||||
// send back the result to the HTTP handler for the InBand part
|
// send back the result to the HTTP handler for the InBand part
|
||||||
request.ResponseChannel <- response
|
request.ResponseChannel <- response
|
||||||
|
if in != nil {
|
||||||
request.Tx = tx
|
request.Tx = tx
|
||||||
// Generate the events for InBand channel
|
// Generate the events for InBand channel
|
||||||
events, err := TxToEvents(request, InBand)
|
events, err := TxToEvents(request, InBand)
|
||||||
|
@ -443,6 +443,7 @@ func (r *WafRunner) Run(t *tomb.Tomb) error {
|
||||||
for _, evt := range events {
|
for _, evt := range events {
|
||||||
r.outChan <- evt
|
r.outChan <- evt
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process outBand
|
// Process outBand
|
||||||
in, tx, err = processReqWithEngine(r.outOfBandWaf, request, request.UUID, OutOfBand)
|
in, tx, err = processReqWithEngine(r.outOfBandWaf, request, request.UUID, OutOfBand)
|
||||||
|
|
Loading…
Reference in a new issue