Skip to content

Commit

Permalink
add Tags method to interruption
Browse files Browse the repository at this point in the history
  • Loading branch information
blotus committed Dec 4, 2023
1 parent b0f8bc4 commit 35deffa
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions experimental/plugins/plugintypes/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Check failure on line 25 in experimental/plugins/plugintypes/rule.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
Tags() []string
}
1 change: 1 addition & 0 deletions internal/actions/deny.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (a *denyFn) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Transaction
Status: r.Status(),
RuleID: rid,
Action: "deny",
Tags: r.Tags(),
})
}

Expand Down
1 change: 1 addition & 0 deletions internal/actions/drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (a *dropFn) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Transaction
Status: r.Status(),
RuleID: rid,
Action: "drop",
Tags: r.Tags(),
})
}

Expand Down
1 change: 1 addition & 0 deletions internal/actions/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (a *redirectFn) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Transac
RuleID: rid,
Action: "redirect",
Data: a.target,
Tags: r.Tags(),
})
}

Expand Down
3 changes: 3 additions & 0 deletions internal/actions/setvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions internal/corazawaf/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/corazawaf/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func (*dummyDenyAction) Evaluate(r plugintypes.RuleMetadata, tx plugintypes.Tran
Status: r.Status(),
RuleID: rid,
Action: "deny",
Tags: r.Tags(),
})
}

Expand Down
3 changes: 3 additions & 0 deletions types/waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ type Interruption struct {

// Parameters used by proxy and redirect
Data string

//Tags of the rule that caused the interruption

Check failure on line 184 in types/waf.go

View workflow job for this annotation

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
Tags []string
}

// BodyBufferOptions is used to feed a coraza.BodyBuffer with parameters
Expand Down

0 comments on commit 35deffa

Please sign in to comment.