Refactoring: Makes transformations to work with new execute signature

This commit is contained in:
Felipe Zimmerle
2019-02-26 15:39:27 -03:00
parent 3490247e39
commit 01a80f8214
91 changed files with 899 additions and 707 deletions

View File

@@ -49,7 +49,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 403
},
@@ -109,7 +109,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 302,
"redirect_url": "http://www.google.com"
@@ -169,7 +169,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 306,
"redirect_url": "http://www.google.com"
@@ -229,7 +229,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 500
},
@@ -288,7 +288,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 500
},
@@ -347,7 +347,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 500
},

View File

@@ -40,7 +40,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 403
},
@@ -97,7 +97,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 403
},
@@ -155,7 +155,7 @@
},
"expected": {
"audit_log": "",
"debug_log": "\\[9\\] Transformation t:trim: \"test",
"debug_log": "\\[9\\] T \\(0\\) t:trim: \"test",
"error_log": "",
"http_code": 403
},

View File

@@ -48,7 +48,7 @@
},
"expected":{
"audit_log":"",
"debug_log":"Transformation t:lowercase: \"test2\"",
"debug_log":"T \\(0\\) t:lowercase: \"test2\"",
"error_log":""
},
"rules":[

View File

@@ -31,7 +31,7 @@
]
},
"expected":{
"debug_log":"Transformation t:trim: \"no need.\""
"debug_log":"T \\(0\\) t:trim: \"no need.\""
},
"rules":[
"SecRuleEngine On",

View File

@@ -51,7 +51,7 @@
]
},
"expected":{
"debug_log":"Transformation t:trim: \"small_text_file"
"debug_log":"T \\(0\\) t:trim: \"small_text_file"
},
"rules":[
"SecRuleEngine On",

View File

@@ -51,7 +51,7 @@
]
},
"expected":{
"debug_log":"Transformation t:trim: \"filedata"
"debug_log":"T \\(0\\) t:trim: \"filedata"
},
"rules":[
"SecRuleEngine On",

View File

@@ -90,8 +90,14 @@ void perform_unit_test(ModSecurityTest<UnitTest> *test, UnitTest *t,
}
delete op;
} else if (t->type == "tfn") {
modsecurity::ModSecStackString in;
modsecurity::ModSecStackString out;
std::string ret;
in.assign(t->input.c_str(), t->input.size());
Transformation *tfn = Transformation::instantiate("t:" + t->name);
std::string ret = tfn->execute(t->input, NULL);
tfn->execute(NULL, in, out);
ret.assign(out.c_str(), out.size());
t->obtained = 1;
t->obtainedOutput = ret;
if (ret != t->output) {