diff --git a/experimental/plugins/plugintypes/rule.go b/experimental/plugins/plugintypes/rule.go index 7e6052579..2e134d1b4 100644 --- a/experimental/plugins/plugintypes/rule.go +++ b/experimental/plugins/plugintypes/rule.go @@ -21,4 +21,7 @@ type RuleMetadata interface { // Status returns the status to set if the rule matches. Status() int + + //Tags returns the tags of the rule. + Tags() []string } diff --git a/internal/actions/deny.go b/internal/actions/deny.go index f3c2fd6bf..a474ce66a 100644 --- a/internal/actions/deny.go +++ b/internal/actions/deny.go @@ -37,6 +37,7 @@ func (a *denyFn) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Transaction Status: r.Status(), RuleID: rid, Action: "deny", + Tags: r.Tags(), }) } diff --git a/internal/actions/drop.go b/internal/actions/drop.go index a1057ba86..75212a154 100644 --- a/internal/actions/drop.go +++ b/internal/actions/drop.go @@ -44,6 +44,7 @@ func (a *dropFn) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Transaction Status: r.Status(), RuleID: rid, Action: "drop", + Tags: r.Tags(), }) } diff --git a/internal/actions/redirect.go b/internal/actions/redirect.go index c47290bb2..68df0f194 100644 --- a/internal/actions/redirect.go +++ b/internal/actions/redirect.go @@ -43,6 +43,7 @@ func (a *redirectFn) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Transac RuleID: rid, Action: "redirect", Data: a.target, + Tags: r.Tags(), }) } diff --git a/internal/actions/setvar_test.go b/internal/actions/setvar_test.go index 7ec7b65b9..07fdff45d 100644 --- a/internal/actions/setvar_test.go +++ b/internal/actions/setvar_test.go @@ -26,6 +26,9 @@ func (md) ParentID() int { func (md) Status() int { return 0 } +func (md) Tags() []string { + return []string{} +} func TestSetvarInit(t *testing.T) { t.Run("no arguments", func(t *testing.T) { diff --git a/internal/corazawaf/rule.go b/internal/corazawaf/rule.go index 819db8e2e..02171d4f2 100644 --- a/internal/corazawaf/rule.go +++ b/internal/corazawaf/rule.go @@ -161,6 +161,10 @@ func (r *Rule) Status() int { return r.DisruptiveStatus } +func (r *Rule) Tags() []string { + return r.Tags_ +} + const chainLevelZero = 0 // Evaluate will evaluate the current rule for the indicated transaction diff --git a/internal/corazawaf/rule_test.go b/internal/corazawaf/rule_test.go index 3018e7f43..009ee40b4 100644 --- a/internal/corazawaf/rule_test.go +++ b/internal/corazawaf/rule_test.go @@ -322,6 +322,7 @@ func (*dummyDenyAction) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Tran Status: r.Status(), RuleID: rid, Action: "deny", + Tags: r.Tags(), }) } diff --git a/types/waf.go b/types/waf.go index 489a42a8f..b097e8d15 100644 --- a/types/waf.go +++ b/types/waf.go @@ -180,6 +180,9 @@ type Interruption struct { // Parameters used by proxy and redirect Data string + + //Tags of the rule that caused the interruption + Tags []string } // BodyBufferOptions is used to feed a coraza.BodyBuffer with parameters