-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SecRuleUpdateActionById directive (#1071)
* feat: add SecRuleUpdateActionById directive Signed-off-by: Felipe Zipitria <[email protected]> * fix: testing rule e2e Signed-off-by: Felipe Zipitria <[email protected]> * fix: apply code review suggestions Signed-off-by: Felipe Zipitria <[email protected]> --------- Signed-off-by: Felipe Zipitria <[email protected]>
- Loading branch information
Showing
5 changed files
with
187 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2024 Juan Pablo Tosso and the OWASP Coraza contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package engine | ||
|
||
import ( | ||
"github.com/corazawaf/coraza/v3/testing/profile" | ||
) | ||
|
||
var _ = profile.RegisterProfile(profile.Profile{ | ||
Meta: profile.Meta{ | ||
Author: "fzipi", | ||
Description: "Test SecRuleUpdateActionById directives", | ||
Enabled: true, | ||
Name: "SecRuleUpdateActionById.yaml", | ||
}, | ||
Tests: []profile.Test{ | ||
{ | ||
Title: "SecRuleUpdateActionById to pass", | ||
Stages: []profile.Stage{ | ||
// Phase 1 | ||
{ | ||
Stage: profile.SubStage{ | ||
Input: profile.StageInput{ | ||
URI: "/phase1?param1=value1", | ||
}, | ||
Output: profile.ExpectedOutput{ | ||
TriggeredRules: []int{ | ||
1004, | ||
}, | ||
}, | ||
}, | ||
}, | ||
// Phase 2 | ||
{ | ||
Stage: profile.SubStage{ | ||
Input: profile.StageInput{ | ||
URI: "/phase2?param2=value2", | ||
}, | ||
Output: profile.ExpectedOutput{ | ||
TriggeredRules: []int{ | ||
1014, | ||
}, | ||
Interruption: &profile.ExpectedInterruption{ | ||
Status: 302, | ||
Data: "https://www.example.com/", | ||
RuleID: 1014, | ||
Action: "redirect", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Rules: ` | ||
SecRule ARGS "@contains value1" "phase:1,id:1004,deny" | ||
SecRule ARGS "@contains value1" "phase:1,id:1005,log" | ||
SecRuleUpdateActionById 1004 "pass" | ||
SecRule ARGS "@contains value2" "phase:2,id:1014,block,deny" | ||
SecRuleUpdateActionById 1014 "redirect:'https://www.example.com/',status:302" | ||
`, | ||
}) |