Skip to content

Commit d810de9

Browse files
michaelgranzow-aviFelipe Zimmerle
authored and
Felipe Zimmerle
committed
#1818: Variable names must match fully, not partially; also revert to hash table lookup instead of linear search; add test case
1 parent 65aa7ae commit d810de9

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

src/collection/backend/in_memory-per_process.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ void InMemoryPerProcess::resolveMultiMatches(const std::string& var,
105105
l->insert(l->begin(), new VariableValue(&m_name, &i.first, &i.second));
106106
}
107107
} else {
108-
for (auto &a : *this) {
109-
if (a.first.compare(0, var.size(), var) == 0) {
110-
l->insert(l->begin(), new VariableValue(&m_name, &var, &a.second));
111-
}
108+
auto range = this->equal_range(var);
109+
for (auto it = range.first; it != range.second; ++it) {
110+
l->insert(l->begin(), new VariableValue(&m_name, &var, &it->second));
112111
}
113112
}
114113
}

test/test-cases/regression/collection-tx.json

+39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
11
[
2+
{
3+
"enabled": 1,
4+
"version_min":300000,
5+
"version_max":0,
6+
"title":"Collection :: TX full vs partial match",
7+
"client":{
8+
"ip":"200.249.12.31",
9+
"port":2313
10+
},
11+
"server":{
12+
"ip":"200.249.12.31",
13+
"port":80
14+
},
15+
"request":{
16+
"headers":{
17+
"User-Agent":"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)"
18+
},
19+
"uri":"/",
20+
"method":"GET",
21+
"http_version":1.1,
22+
"body":""
23+
},
24+
"response":{
25+
"headers":{
26+
"Content-Type":"text/xml; charset=utf-8\n"
27+
},
28+
"body":[
29+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
30+
]
31+
},
32+
"expected":{
33+
"http_code":200
34+
},
35+
"rules":[
36+
"SecRuleEngine On",
37+
"SecRule REMOTE_ADDR \"@unconditionalMatch\" \"id:1,deny,setvar:TX.partial_match=1,chain\"",
38+
"SecRule TX.partial \"@gt 0\" \"id:2,t:lowercase,t:none,status:444\""
39+
]
40+
},
241
{
342
"enabled":1,
443
"version_min":300000,

0 commit comments

Comments
 (0)