Skip to content

Commit 776e76c

Browse files
committed
Added test for nested macro
1 parent d037843 commit 776e76c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/regression/rule/00-basics.t

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,25 @@
8989
GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt?test=value",
9090
),
9191
},
92+
{
93+
type => "rule",
94+
comment => "SecRule (chain) with nested macro",
95+
conf => qq(
96+
SecRuleEngine On
97+
SecDebugLog $ENV{DEBUG_LOG}
98+
SecDebugLogLevel 9
99+
SecAction "id:10000,phase:1,t:none,setvar:tx.10001_counter=1,setvar:tx.10001_counter2=1"
100+
SecRule ARGS "\@rx (\\\d+)=(\\\d+)" "id:10001,phase:2,deny,nolog,t:none,capture,setvar:'tx.10001_%{tx.10001_counter}_lval=%{tx.1}',setvar:'tx.10001_%{tx.10001_counter}_rval=%{tx.2}',setvar:'tx.10001_counter=+1',chain"
101+
SecRule TX:/10001_\\\d+_lval/ "\@streq %{tx.10001_%{tx.10001_counter2}_rval}" "setvar:'tx.10001_counter2=+1'"
102+
),
103+
match_log => {
104+
error => [ qr/ModSecurity: /, 1 ],
105+
debug => [ qr/Set variable "tx.10001_1_rval" to "1"\..*Resolved macro \%\{tx.10001_counter\} to: 2.*Set variable "tx.10001_2_rval" to "1"/s, 1 ],
106+
},
107+
match_response => {
108+
status => qr/^403$/,
109+
},
110+
request => new HTTP::Request(
111+
GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt?a=1=1&b=2=1",
112+
),
113+
},

0 commit comments

Comments
 (0)