Skip to content

Commit

Permalink
expose DisruptiveAction() in MatchedRules
Browse files Browse the repository at this point in the history
  • Loading branch information
blotus committed Dec 22, 2023
1 parent 41d5358 commit 803b08f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/corazarules/rule_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ var DisruptiveActionMap = map[string]DisruptiveAction{
"redirect": DisruptiveActionRedirect,
}

var disruptiveActionMapStr = map[DisruptiveAction]string{
DisruptiveActionAllow: "allow",
DisruptiveActionDeny: "deny",
DisruptiveActionDrop: "drop",
DisruptiveActionPass: "pass",
DisruptiveActionRedirect: "redirect",
}

// MatchedRule contains a list of macro expanded messages,
// matched variables and a pointer to the rule
type MatchedRule struct {
Expand Down Expand Up @@ -142,6 +150,10 @@ func (mr *MatchedRule) Rule() types.RuleMetadata {
return mr.Rule_
}

func (mr *MatchedRule) DisruptiveAction() string {
return disruptiveActionMapStr[mr.DisruptiveAction_]
}

const maxSizeLogMessage = 200

func (mr MatchedRule) writeDetails(log *strings.Builder, matchData types.MatchData) {
Expand Down
2 changes: 2 additions & 0 deletions types/rule_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ type MatchedRule interface {

AuditLog() string
ErrorLog() string

DisruptiveAction() string
}

0 comments on commit 803b08f

Please sign in to comment.