Adds offset regression tests and assorted fixes on var's offsets

This commit is contained in:
Felipe Zimmerle
2017-02-14 15:46:52 -03:00
committed by Felipe Zimmerle
parent 795994bb0e
commit 4ad3574cf2
25 changed files with 2228 additions and 117 deletions

View File

@@ -21,4 +21,12 @@
./test/fuzzer
./test/libfuzzer
./src/parser/seclang-parser.tab.cc
./src/unique_id.cc:226
./test/unit/unit.cc:84
./test/unit/unit.cc:82
./headers/modsecurity/rule.h:110
./test/regression/regression.cc:44
./test/benchmark/owasp-v3/util/av-scanning/runAV/common.h
./src/audit_log/writer/parallel.cc:28
./src/macro_expansion.c
Total errors found

View File

@@ -31,6 +31,7 @@ class CustomDebugLog : public modsecurity::debug_log::DebugLog {
void write(int level, const std::string& message) override;
bool contains(const std::string& pattern);
std::string log_messages();
std::string error_log_messages();
private:
std::stringstream m_log;

View File

@@ -475,7 +475,7 @@ int main(int argc, char **argv) {
if (r->passed == true && r->skipped == false) {
passed++;
} else if (r->skipped == false) {
if (test.m_automake_output && 1 == 0) {
if (test.m_automake_output) {
// m_automake_output
} else {
std::cout << KRED << "Test failed." << RESET << KWHT \

View File

@@ -66,15 +66,15 @@ inline std::vector<std::string> RegressionTest::yajl_array_to_vec_str(
}
inline std::unordered_map<std::string, std::string>
inline std::vector<std::pair<std::string, std::string>>
RegressionTest::yajl_array_to_map(const yajl_val &node) {
std::unordered_map<std::string, std::string> vec;
std::vector<std::pair<std::string, std::string>> vec;
for (int z = 0; z < node->u.object.len; z++) {
const char *key = node->u.object.keys[z];
yajl_val val3 = node->u.object.values[z];
const char *value = YAJL_GET_STRING(val3);
std::pair<std::string, std::string> a(key, value);
vec.insert(a);
vec.push_back(a);
}
return vec;
}

View File

@@ -18,8 +18,10 @@
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <map>
#include <vector>
#include <string>
#include <utility>
#ifndef TEST_REGRESSION_REGRESSION_TEST_H_
#define TEST_REGRESSION_REGRESSION_TEST_H_
@@ -44,8 +46,8 @@ class RegressionTest {
int version_max;
int github_issue;
std::unordered_map<std::string, std::string> request_headers;
std::unordered_map<std::string, std::string> response_headers;
std::vector<std::pair<std::string, std::string>> request_headers;
std::vector<std::pair<std::string, std::string>> response_headers;
std::string request_body;
std::string response_body;
std::string response_protocol;
@@ -68,8 +70,8 @@ class RegressionTest {
static inline std::string yajl_array_to_str(const yajl_val &node);
static inline std::vector<std::string> yajl_array_to_vec_str(
const yajl_val &node);
static inline std::unordered_map<std::string,
std::string> yajl_array_to_map(const yajl_val &node);
static inline std::vector<std::pair<std::string, std::string>>
yajl_array_to_map(const yajl_val &node);
int http_code;
std::string redirect_url;

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -51,7 +51,7 @@
]
},
"expected":{
"debug_log":"Content-Type: multipart/form-data; boundary=------------"
"debug_log":"Multipart: Boundary: --------------------------756b6d74fa1a8ee2"
},
"rules":[
"SecRuleEngine On",

View File

@@ -51,7 +51,7 @@
]
},
"expected":{
"debug_log":"Target value: \"Content-Type Last-Modified Date\" \\(Variable: RESPONSE_HEADERS_NAMES\\)"
"debug_log":"Target value: \"Date Last-Modified Content-Type\" \\(Variable: RESPONSE_HEADERS_NAMES\\)"
},
"rules":[
"SecRuleEngine On",

View File

@@ -240,7 +240,7 @@ int main(int argc, char **argv) {
} else {
for (auto &i : r) {
if (i->skipped == true) {
skp++;
skp++;
}
}
std::cout << KRED << r.size()-skp << " tests failed.";
@@ -275,7 +275,7 @@ int main(int argc, char **argv) {
int skp = 0;
for (auto &i : results) {
if (i->skipped == true) {
skp++;
skp++;
}
}
std::cout << KRED << results.size()-skp << " failed.";