Skip to content

Commit 6ab464a

Browse files
committed
negative lookup on the key name instead of COLLECTION:key
1 parent 47dd9c5 commit 6ab464a

File tree

2 files changed

+86
-6
lines changed

2 files changed

+86
-6
lines changed

src/rule.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ bool Rule::evaluate(Transaction *trans,
699699
const std::string &value = v->getValue();
700700
const std::string &key = v->getKeyWithCollection();
701701

702-
if (exclusion.contains(v->getKeyWithCollection()) ||
702+
if (exclusion.contains(v->getKey()) ||
703703
std::find_if(trans->m_ruleRemoveTargetById.begin(),
704704
trans->m_ruleRemoveTargetById.end(),
705705
[&, v, this](std::pair<int, std::string> &m) -> bool {
@@ -710,7 +710,7 @@ bool Rule::evaluate(Transaction *trans,
710710
v = NULL;
711711
continue;
712712
}
713-
if (exclusion.contains(v->getKeyWithCollection()) ||
713+
if (exclusion.contains(v->getKey()) ||
714714
std::find_if(trans->m_ruleRemoveTargetByTag.begin(),
715715
trans->m_ruleRemoveTargetByTag.end(),
716716
[&, v, trans, this](std::pair<std::string, std::string> &m) -> bool {

test/test-cases/regression/config-update-target-by-tag.json

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"enabled":1,
44
"version_min":300000,
5-
"title":"SecRuleUpdateTargetByTag (1/4)",
5+
"title":"SecRuleUpdateTargetByTag (1/6)",
66
"client":{
77
"ip":"200.249.12.31",
88
"port":123
@@ -42,7 +42,7 @@
4242
{
4343
"enabled":1,
4444
"version_min":300000,
45-
"title":"SecRuleUpdateTargetByTag (2/4)",
45+
"title":"SecRuleUpdateTargetByTag (2/6)",
4646
"client":{
4747
"ip":"200.249.12.31",
4848
"port":123
@@ -82,7 +82,7 @@
8282
{
8383
"enabled":1,
8484
"version_min":300000,
85-
"title":"SecRuleUpdateTargetByTag (3/4)",
85+
"title":"SecRuleUpdateTargetByTag (3/6)",
8686
"client":{
8787
"ip":"200.249.12.31",
8888
"port":123
@@ -122,7 +122,7 @@
122122
{
123123
"enabled":1,
124124
"version_min":300000,
125-
"title":"SecRuleUpdateTargetByTag (4/4)",
125+
"title":"SecRuleUpdateTargetByTag (4/6)",
126126
"client":{
127127
"ip":"200.249.12.31",
128128
"port":123
@@ -158,5 +158,85 @@
158158
"SecRuleUpdateTargetByTag test !ARGS:/ke/",
159159
"SecRule ARGS \"@contains value\" \"id:1,pass,t:trim,tag:'test',deny\""
160160
]
161+
},
162+
{
163+
"enabled":1,
164+
"version_min":300000,
165+
"title":"SecRuleUpdateTargetByTag Test (5/6) Regex with match anchored at beginning of Subject",
166+
"client":{
167+
"ip":"200.249.12.31",
168+
"port":123
169+
},
170+
"server":{
171+
"ip":"200.249.12.31",
172+
"port":80
173+
},
174+
"request":{
175+
"headers":{
176+
"Host":"localhost",
177+
"User-Agent":"curl/7.38.0",
178+
"Accept":"*/*"
179+
},
180+
"uri":"/?key=value&ref=something",
181+
"method":"GET"
182+
},
183+
"response":{
184+
"headers":{
185+
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
186+
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
187+
"Content-Type":"text/html"
188+
},
189+
"body":[
190+
"no need."
191+
]
192+
},
193+
"expected":{
194+
"http_code": 200
195+
},
196+
"rules":[
197+
"SecRuleEngine On",
198+
"SecRuleUpdateTargetByTag test !ARGS:'/(?!ref)/'",
199+
"SecRule ARGS \"@contains value\" \"id:1,pass,t:trim,tag:'test',deny\""
200+
]
201+
},
202+
{
203+
"enabled":1,
204+
"version_min":300000,
205+
"title":"SecRuleUpdateTargetByTag Test (6/6) Regex with match anchored at beginning of Subject",
206+
"client":{
207+
"ip":"200.249.12.31",
208+
"port":123
209+
},
210+
"server":{
211+
"ip":"200.249.12.31",
212+
"port":80
213+
},
214+
"request":{
215+
"headers":{
216+
"Host":"localhost",
217+
"User-Agent":"curl/7.38.0",
218+
"Accept":"*/*"
219+
},
220+
"uri":"/?key=value&ref=something",
221+
"method":"GET"
222+
},
223+
"response":{
224+
"headers":{
225+
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
226+
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
227+
"Content-Type":"text/html"
228+
},
229+
"body":[
230+
"no need."
231+
]
232+
},
233+
"expected":{
234+
"http_code": 200
235+
},
236+
"rules":[
237+
"SecRuleEngine On",
238+
"SecRuleUpdateTargetByTag test !ARGS:'/^ref/'",
239+
"SecRule ARGS \"@contains something\" \"id:1,pass,t:trim,tag:'test',deny\""
240+
]
161241
}
162242
]

0 commit comments

Comments
 (0)