Having _NAMES, variables proxied

Some variables share content with others; that is the case
for ARGS and ARGS_NAMES. Those are different in value, as
ARGS_NAMES holds the key name as value.

Instead of duplicating the strings for the different
collections, this patch unifies the collection in radix,
avoiding memory fragmentation. It is currently doing some
fragmentation while resolving the variable, but to be
mitigated by shared_ptr is VariableValues, a different
change.

TODO: place others variables such as COOKIE*NAMES to use
the same proxy.
This commit is contained in:
Felipe Zimmerle
2021-01-18 14:58:56 -03:00
parent dd458dedb8
commit e8bd2151f2
7 changed files with 359 additions and 16 deletions

View File

@@ -164,6 +164,58 @@
"SecRuleEngine On",
"SecRule ARGS_NAMES \"@contains test \" \"id:1,phase:3,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"title":"Testing Variables :: ARGS_POST_NAMES (3/x)",
"client":{
"ip":"200.249.12.31",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*",
"Content-Length":"330",
"Content-Type":"multipart/form-data; boundary=0000",
"Expect":"100-continue"
},
"uri":"/",
"method":"POST",
"body":[
"--0000\r",
"Content-Disposition: form-data; name=\"name1\"\r",
"\r",
"content1\r",
"--0000\r",
"Content-Disposition: form-data; name=\"name2\"\r",
"\r",
"content2\r",
"--0000--\r"
]
},
"response":{
"headers":{
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"name1\" \\(Variable: ARGS_NAMES\\)"
},
"rules":[
"SecRuleEngine On",
"SecRequestBodyAccess On",
"SecRule ARGS_NAMES \"@contains test \" \"id:1,phase:3,pass,t:trim\""
]
}
]