mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Code cosmetics: reduce the amount of cppcheck warnings
This commit is contained in:
parent
21400ba454
commit
d5fe21ce3c
@ -227,10 +227,10 @@ class Assay {
|
|||||||
int getResponseBodyLenth();
|
int getResponseBodyLenth();
|
||||||
|
|
||||||
std::list<std::pair<std::string, std::string>>
|
std::list<std::pair<std::string, std::string>>
|
||||||
resolve_variable(std::string var);
|
resolve_variable(const std::string& var);
|
||||||
std::string* resolve_variable_first(std::string);
|
std::string* resolve_variable_first(const std::string& key);
|
||||||
std::string* resolve_variable_first(const std::string collectionName,
|
std::string* resolve_variable_first(const std::string& collectionName,
|
||||||
std::string var);
|
const std::string& var);
|
||||||
|
|
||||||
void store_variable(std::string, std::string value);
|
void store_variable(std::string, std::string value);
|
||||||
bool update_variable_first(std::string var, const std::string &value);
|
bool update_variable_first(std::string var, const std::string &value);
|
||||||
|
@ -47,6 +47,7 @@ class Rules : public RulesProperties {
|
|||||||
Rules()
|
Rules()
|
||||||
: debugLog(NULL),
|
: debugLog(NULL),
|
||||||
RulesProperties(NULL),
|
RulesProperties(NULL),
|
||||||
|
m_referenceCount(0),
|
||||||
unicode_codepage(0) {
|
unicode_codepage(0) {
|
||||||
unicode_map_table = reinterpret_cast<int *>(
|
unicode_map_table = reinterpret_cast<int *>(
|
||||||
malloc(sizeof(int)*65536));
|
malloc(sizeof(int)*65536));
|
||||||
@ -55,6 +56,7 @@ class Rules : public RulesProperties {
|
|||||||
|
|
||||||
explicit Rules(DebugLog *customLog)
|
explicit Rules(DebugLog *customLog)
|
||||||
: debugLog(NULL),
|
: debugLog(NULL),
|
||||||
|
m_referenceCount(0),
|
||||||
unicode_codepage(0),
|
unicode_codepage(0),
|
||||||
RulesProperties(customLog) {
|
RulesProperties(customLog) {
|
||||||
unicode_map_table = reinterpret_cast<int *>(
|
unicode_map_table = reinterpret_cast<int *>(
|
||||||
|
@ -45,8 +45,11 @@ class RulesProperties {
|
|||||||
customDebugLog(NULL),
|
customDebugLog(NULL),
|
||||||
remoteRulesActionOnFailed(AbortOnFailedRemoteRulesAction),
|
remoteRulesActionOnFailed(AbortOnFailedRemoteRulesAction),
|
||||||
requestBodyLimit(0),
|
requestBodyLimit(0),
|
||||||
|
secRequestBodyAccess(false),
|
||||||
|
secResponseBodyAccess(false),
|
||||||
requestBodyLimitAction(ProcessPartialBodyLimitAction),
|
requestBodyLimitAction(ProcessPartialBodyLimitAction),
|
||||||
responseBodyLimit(0),
|
responseBodyLimit(0),
|
||||||
|
debugLevel(0),
|
||||||
responseBodyLimitAction(ProcessPartialBodyLimitAction),
|
responseBodyLimitAction(ProcessPartialBodyLimitAction),
|
||||||
secRuleEngine(DetectionOnlyRuleEngine) { }
|
secRuleEngine(DetectionOnlyRuleEngine) { }
|
||||||
|
|
||||||
@ -54,6 +57,9 @@ class RulesProperties {
|
|||||||
: audit_log(NULL),
|
: audit_log(NULL),
|
||||||
customDebugLog(customDebugLog),
|
customDebugLog(customDebugLog),
|
||||||
remoteRulesActionOnFailed(AbortOnFailedRemoteRulesAction),
|
remoteRulesActionOnFailed(AbortOnFailedRemoteRulesAction),
|
||||||
|
secRequestBodyAccess(false),
|
||||||
|
secResponseBodyAccess(false),
|
||||||
|
debugLevel(0),
|
||||||
requestBodyLimit(0),
|
requestBodyLimit(0),
|
||||||
requestBodyLimitAction(ProcessPartialBodyLimitAction),
|
requestBodyLimitAction(ProcessPartialBodyLimitAction),
|
||||||
responseBodyLimit(0),
|
responseBodyLimit(0),
|
||||||
@ -157,14 +163,12 @@ class RulesProperties {
|
|||||||
|
|
||||||
DebugLog *customDebugLog;
|
DebugLog *customDebugLog;
|
||||||
|
|
||||||
int sec_audit_type;
|
bool secRequestBodyAccess;
|
||||||
bool sec_audit_engine;
|
bool secResponseBodyAccess;
|
||||||
bool sec_request_body_access;
|
|
||||||
bool sec_response_body_access;
|
|
||||||
std::string audit_log_path;
|
std::string audit_log_path;
|
||||||
std::string audit_log_parts;
|
std::string audit_log_parts;
|
||||||
std::string debug_log_path;
|
std::string debug_log_path;
|
||||||
int debug_level;
|
int debugLevel;
|
||||||
std::list<std::string> components;
|
std::list<std::string> components;
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ SetVar::SetVar(std::string action)
|
|||||||
|
|
||||||
|
|
||||||
bool SetVar::init(std::string *error) {
|
bool SetVar::init(std::string *error) {
|
||||||
size_t pos = std::string::npos;
|
size_t pos;
|
||||||
|
|
||||||
// Resolv operation
|
// Resolv operation
|
||||||
operation = setToOne;
|
operation = setToOne;
|
||||||
|
@ -37,7 +37,7 @@ namespace transformations {
|
|||||||
std::string CssDecode::evaluate(std::string value,
|
std::string CssDecode::evaluate(std::string value,
|
||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
char *tmp = strdup(value.c_str());
|
char *tmp = strdup(value.c_str());
|
||||||
int res = css_decode_inplace((unsigned char *)tmp, value.size());
|
css_decode_inplace((unsigned char *)tmp, value.size());
|
||||||
std::string ret(tmp, 0, value.size());
|
std::string ret(tmp, 0, value.size());
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -37,7 +37,7 @@ namespace transformations {
|
|||||||
std::string HtmlEntityDecode::evaluate(std::string value,
|
std::string HtmlEntityDecode::evaluate(std::string value,
|
||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
char *tmp = strdup(value.c_str());
|
char *tmp = strdup(value.c_str());
|
||||||
int res = html_entities_decode_inplace((unsigned char *)tmp, value.size());
|
html_entities_decode_inplace((unsigned char *)tmp, value.size());
|
||||||
std::string ret("");
|
std::string ret("");
|
||||||
ret.assign(tmp);
|
ret.assign(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
@ -37,7 +37,7 @@ namespace transformations {
|
|||||||
std::string JsDecode::evaluate(std::string value,
|
std::string JsDecode::evaluate(std::string value,
|
||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
char *tmp = strdup(value.c_str());
|
char *tmp = strdup(value.c_str());
|
||||||
int res = js_decode_nonstrict_inplace((unsigned char *)tmp, value.size());
|
js_decode_nonstrict_inplace((unsigned char *)tmp, value.size());
|
||||||
std::string ret("");
|
std::string ret("");
|
||||||
ret.assign(tmp);
|
ret.assign(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
@ -38,7 +38,7 @@ std::string NormalisePathWin::evaluate(std::string value,
|
|||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
int changed;
|
int changed;
|
||||||
char *tmp = strdup(value.c_str());
|
char *tmp = strdup(value.c_str());
|
||||||
int res = normalize_path_inplace((unsigned char *)tmp,
|
normalize_path_inplace((unsigned char *)tmp,
|
||||||
value.size(), 1, &changed);
|
value.size(), 1, &changed);
|
||||||
std::string ret("");
|
std::string ret("");
|
||||||
ret.assign(tmp);
|
ret.assign(tmp);
|
||||||
|
@ -38,7 +38,7 @@ std::string UrlDecodeUni::evaluate(std::string value,
|
|||||||
Assay *assay) {
|
Assay *assay) {
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
char *tmp = strdup(value.c_str());
|
char *tmp = strdup(value.c_str());
|
||||||
int res = urldecode_uni_nonstrict_inplace_ex(assay, (unsigned char *)tmp,
|
urldecode_uni_nonstrict_inplace_ex(assay, (unsigned char *)tmp,
|
||||||
value.size(), &changed);
|
value.size(), &changed);
|
||||||
std::string ret("");
|
std::string ret("");
|
||||||
ret.assign(tmp);
|
ret.assign(tmp);
|
||||||
|
16
src/assay.cc
16
src/assay.cc
@ -579,7 +579,6 @@ int Assay::processRequestBody() {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char sep1 = '&';
|
char sep1 = '&';
|
||||||
const char *pos = strchr(content.c_str(), '?');
|
|
||||||
|
|
||||||
std::vector<std::string> key_value = split(content.c_str(), sep1);
|
std::vector<std::string> key_value = split(content.c_str(), sep1);
|
||||||
|
|
||||||
@ -741,7 +740,6 @@ int Assay::processResponseHeaders() {
|
|||||||
*/
|
*/
|
||||||
int Assay::addResponseHeader(const std::string& key,
|
int Assay::addResponseHeader(const std::string& key,
|
||||||
const std::string& value) {
|
const std::string& value) {
|
||||||
std::string *names = resolve_variable_first("RESPONSE_HEADERS_NAMES");
|
|
||||||
m_responseHeadersNames->assign(*m_responseHeadersNames + " " + key);
|
m_responseHeadersNames->assign(*m_responseHeadersNames + " " + key);
|
||||||
|
|
||||||
this->store_variable("RESPONSE_HEADERS:" + key, value);
|
this->store_variable("RESPONSE_HEADERS:" + key, value);
|
||||||
@ -1324,7 +1322,7 @@ void Assay::delete_variable(std::string key) {
|
|||||||
|
|
||||||
|
|
||||||
std::list<std::pair<std::string, std::string>>
|
std::list<std::pair<std::string, std::string>>
|
||||||
Assay::resolve_variable(std::string var) {
|
Assay::resolve_variable(const std::string& var) {
|
||||||
std::list<std::pair<std::string, std::string>> l;
|
std::list<std::pair<std::string, std::string>> l;
|
||||||
std::pair<std::string, std::string> pair;
|
std::pair<std::string, std::string> pair;
|
||||||
|
|
||||||
@ -1335,7 +1333,7 @@ std::list<std::pair<std::string, std::string>>
|
|||||||
l.push_back(pair);
|
l.push_back(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l.size() == 0) {
|
if (l.empty()) {
|
||||||
for (auto &x : m_variables_strings) {
|
for (auto &x : m_variables_strings) {
|
||||||
if ((x.first.substr(0, var.size() + 1).compare(var + ":") != 0)
|
if ((x.first.substr(0, var.size() + 1).compare(var + ":") != 0)
|
||||||
&& (x.first != var)) {
|
&& (x.first != var)) {
|
||||||
@ -1359,7 +1357,7 @@ std::list<std::pair<std::string, std::string>>
|
|||||||
l.push_back(pair);
|
l.push_back(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l.size() == 0) {
|
if (l.empty()) {
|
||||||
for (auto &x : *a.second) {
|
for (auto &x : *a.second) {
|
||||||
if ((x.first.substr(0, var.size() + 1).compare(var + ":") != 0)
|
if ((x.first.substr(0, var.size() + 1).compare(var + ":") != 0)
|
||||||
&& (x.first != var)) {
|
&& (x.first != var)) {
|
||||||
@ -1383,7 +1381,7 @@ void Assay::serverLog(const std::string& msg) {
|
|||||||
std::cerr << "Server log is not ready : " << msg << std::endl;
|
std::cerr << "Server log is not ready : " << msg << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string* Assay::resolve_variable_first(std::string var) {
|
std::string* Assay::resolve_variable_first(const std::string& var) {
|
||||||
auto range = m_variables_strings.equal_range(var);
|
auto range = m_variables_strings.equal_range(var);
|
||||||
|
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
for (auto it = range.first; it != range.second; ++it) {
|
||||||
@ -1400,8 +1398,8 @@ std::string* Assay::resolve_variable_first(std::string var) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string* Assay::resolve_variable_first(const std::string collectionName,
|
std::string* Assay::resolve_variable_first(const std::string& collectionName,
|
||||||
std::string var) {
|
const std::string& var) {
|
||||||
for (auto &a : collections) {
|
for (auto &a : collections) {
|
||||||
if (tolower(a.first) == tolower(collectionName)) {
|
if (tolower(a.first) == tolower(collectionName)) {
|
||||||
auto range = a.second->equal_range(toupper(collectionName)
|
auto range = a.second->equal_range(toupper(collectionName)
|
||||||
@ -1418,9 +1416,9 @@ std::string* Assay::resolve_variable_first(const std::string collectionName,
|
|||||||
void Assay::setCollection(const std::string& collectionName,
|
void Assay::setCollection(const std::string& collectionName,
|
||||||
const std::string& variableName,
|
const std::string& variableName,
|
||||||
const std::string& targetValue) {
|
const std::string& targetValue) {
|
||||||
ModSecurityStringVariables *collection;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ModSecurityStringVariables *collection;
|
||||||
collection = collections.at(toupper(collectionName));
|
collection = collections.at(toupper(collectionName));
|
||||||
collection->storeOrUpdateVariable(toupper(collectionName) + ":"
|
collection->storeOrUpdateVariable(toupper(collectionName) + ":"
|
||||||
+ variableName, targetValue);
|
+ variableName, targetValue);
|
||||||
|
@ -47,7 +47,6 @@ inline std::string AuditLogWriterParallel::logFilePath(time_t *t,
|
|||||||
int part) {
|
int part) {
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
char tstr[300];
|
char tstr[300];
|
||||||
size_t len;
|
|
||||||
std::string name("");
|
std::string name("");
|
||||||
|
|
||||||
localtime_r(t, &timeinfo);
|
localtime_r(t, &timeinfo);
|
||||||
|
@ -27,7 +27,7 @@ int ValidateUrlEncoding::validate_url_encoding(const char *input,
|
|||||||
uint64_t input_length) {
|
uint64_t input_length) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((input == NULL) || (input_length < 0)) {
|
if ((input == NULL) || (input_length <= 0)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ bool VerifyCC::evaluate(Assay *assay, const std::string &i) {
|
|||||||
int offset = 0;
|
int offset = 0;
|
||||||
bool is_cc = false;
|
bool is_cc = false;
|
||||||
int target_length = i.length();
|
int target_length = i.length();
|
||||||
const char *target = i.c_str();
|
|
||||||
|
|
||||||
for (offset = 0; offset < target_length; offset++) {
|
for (offset = 0; offset < target_length; offset++) {
|
||||||
std::string shiftedString(i, offset, i.length() - offset);
|
std::string shiftedString(i, offset, i.length() - offset);
|
||||||
|
@ -311,19 +311,19 @@ expression:
|
|||||||
}
|
}
|
||||||
| CONFIG_DIR_REQ_BODY SPACE CONFIG_VALUE_ON
|
| CONFIG_DIR_REQ_BODY SPACE CONFIG_VALUE_ON
|
||||||
{
|
{
|
||||||
driver.sec_request_body_access = true;
|
driver.secRequestBodyAccess = true;
|
||||||
}
|
}
|
||||||
| CONFIG_DIR_REQ_BODY SPACE CONFIG_VALUE_OFF
|
| CONFIG_DIR_REQ_BODY SPACE CONFIG_VALUE_OFF
|
||||||
{
|
{
|
||||||
driver.sec_request_body_access = false;
|
driver.secRequestBodyAccess = false;
|
||||||
}
|
}
|
||||||
| CONFIG_DIR_RES_BODY SPACE CONFIG_VALUE_ON
|
| CONFIG_DIR_RES_BODY SPACE CONFIG_VALUE_ON
|
||||||
{
|
{
|
||||||
driver.sec_request_body_access = true;
|
driver.secResponseBodyAccess = true;
|
||||||
}
|
}
|
||||||
| CONFIG_DIR_RES_BODY SPACE CONFIG_VALUE_OFF
|
| CONFIG_DIR_RES_BODY SPACE CONFIG_VALUE_OFF
|
||||||
{
|
{
|
||||||
driver.sec_request_body_access = false;
|
driver.secResponseBodyAccess = false;
|
||||||
}
|
}
|
||||||
| CONFIG_COMPONENT_SIG
|
| CONFIG_COMPONENT_SIG
|
||||||
{
|
{
|
||||||
@ -332,7 +332,7 @@ expression:
|
|||||||
/* Debug log: start */
|
/* Debug log: start */
|
||||||
| CONFIG_DIR_DEBUG_LVL
|
| CONFIG_DIR_DEBUG_LVL
|
||||||
{
|
{
|
||||||
driver.debug_level = atoi($1.c_str());
|
driver.debugLevel = atoi($1.c_str());
|
||||||
}
|
}
|
||||||
| CONFIG_DIR_DEBUG_LOG
|
| CONFIG_DIR_DEBUG_LOG
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ bool MultipartBlob::processContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool contentTypeLine = processContentTypeLine(secondLine);
|
bool contentTypeLine = processContentTypeLine(secondLine);
|
||||||
if (dispositionLine == false) {
|
if (contentTypeLine == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
src/rules.cc
18
src/rules.cc
@ -188,12 +188,10 @@ int Rules::merge(Driver *from) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->secRuleEngine = from->secRuleEngine;
|
this->secRuleEngine = from->secRuleEngine;
|
||||||
this->sec_audit_type = from->sec_audit_type;
|
this->secRequestBodyAccess = from->secRequestBodyAccess;
|
||||||
this->sec_audit_engine = from->sec_audit_engine;
|
this->secResponseBodyAccess = from->secResponseBodyAccess;
|
||||||
this->sec_request_body_access = from->sec_request_body_access;
|
|
||||||
this->sec_response_body_access = from->sec_response_body_access;
|
|
||||||
this->debug_log_path = from->debug_log_path;
|
this->debug_log_path = from->debug_log_path;
|
||||||
this->debug_level = from->debug_level;
|
this->debugLevel = from->debugLevel;
|
||||||
this->components = from->components;
|
this->components = from->components;
|
||||||
this->requestBodyLimit = from->requestBodyLimit;
|
this->requestBodyLimit = from->requestBodyLimit;
|
||||||
this->responseBodyLimit = from->responseBodyLimit;
|
this->responseBodyLimit = from->responseBodyLimit;
|
||||||
@ -210,7 +208,7 @@ int Rules::merge(Driver *from) {
|
|||||||
this->audit_log = from->audit_log;
|
this->audit_log = from->audit_log;
|
||||||
this->audit_log->refCountIncrease();
|
this->audit_log->refCountIncrease();
|
||||||
|
|
||||||
this->debugLog->setDebugLevel(this->debug_level);
|
this->debugLog->setDebugLevel(this->debugLevel);
|
||||||
this->debugLog->setOutputFile(this->debug_log_path);
|
this->debugLog->setOutputFile(this->debug_log_path);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -228,10 +226,8 @@ int Rules::merge(Rules *from) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->secRuleEngine = from->secRuleEngine;
|
this->secRuleEngine = from->secRuleEngine;
|
||||||
this->sec_audit_type = from->sec_audit_type;
|
this->secRequestBodyAccess = from->secRequestBodyAccess;
|
||||||
this->sec_audit_engine = from->sec_audit_engine;
|
this->secResponseBodyAccess = from->secResponseBodyAccess;
|
||||||
this->sec_request_body_access = from->sec_request_body_access;
|
|
||||||
this->sec_response_body_access = from->sec_response_body_access;
|
|
||||||
this->components = from->components;
|
this->components = from->components;
|
||||||
this->requestBodyLimit = from->requestBodyLimit;
|
this->requestBodyLimit = from->requestBodyLimit;
|
||||||
this->responseBodyLimit = from->responseBodyLimit;
|
this->responseBodyLimit = from->responseBodyLimit;
|
||||||
@ -248,7 +244,7 @@ int Rules::merge(Rules *from) {
|
|||||||
this->audit_log = from->audit_log;
|
this->audit_log = from->audit_log;
|
||||||
this->audit_log->refCountIncrease();
|
this->audit_log->refCountIncrease();
|
||||||
|
|
||||||
this->debugLog->setDebugLevel(this->debug_level);
|
this->debugLog->setDebugLevel(this->debugLevel);
|
||||||
this->debugLog->setOutputFile(this->debug_log_path);
|
this->debugLog->setOutputFile(this->debug_log_path);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -190,7 +190,7 @@ std::string UniqueId::ethernetMacAddress() {
|
|||||||
|
|
||||||
if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
|
if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
|
||||||
free(pAdapterInfo);
|
free(pAdapterInfo);
|
||||||
pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO *>malloc(ulOutBufLen));
|
pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO *>(malloc(ulOutBufLen));
|
||||||
if (!pAdapterInfo) {
|
if (!pAdapterInfo) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ double random_number(const double from, const double to) {
|
|||||||
|
|
||||||
|
|
||||||
std::string dash_if_empty(const std::string& str) {
|
std::string dash_if_empty(const std::string& str) {
|
||||||
if (&str == NULL || str.empty()) {
|
if (str.empty()) {
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,10 +80,9 @@ IpTree::~IpTree() {
|
|||||||
|
|
||||||
bool IpTree::addFromBuffer(std::istream *ss, std::string *error) {
|
bool IpTree::addFromBuffer(std::istream *ss, std::string *error) {
|
||||||
char *error_msg = NULL;
|
char *error_msg = NULL;
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
for (std::string line; std::getline(*ss, line); ) {
|
for (std::string line; std::getline(*ss, line); ) {
|
||||||
res = ip_tree_from_param(line.c_str(), &m_tree, &error_msg);
|
int res = ip_tree_from_param(line.c_str(), &m_tree, &error_msg);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
if (error_msg != NULL) {
|
if (error_msg != NULL) {
|
||||||
error->assign(error_msg);
|
error->assign(error_msg);
|
||||||
|
@ -354,7 +354,7 @@ std::ostream& operator<<(std::ostream& out, MD5 md5)
|
|||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
std::string md5(const std::string str)
|
std::string md5(const std::string& str)
|
||||||
{
|
{
|
||||||
MD5 md5 = MD5(str);
|
MD5 md5 = MD5(str);
|
||||||
|
|
||||||
|
@ -88,6 +88,6 @@ private:
|
|||||||
static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
|
static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string md5(const std::string str);
|
std::string md5(const std::string& str);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -53,7 +53,6 @@ int regex_search(const std::string& s, SMatch *match,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int regex_search(const std::string& s, Regex regex) {
|
int regex_search(const std::string& s, Regex regex) {
|
||||||
std::string match;
|
|
||||||
pcrecpp::RE re(regex.pattern);
|
pcrecpp::RE re(regex.pattern);
|
||||||
return re.PartialMatch(s);
|
return re.PartialMatch(s);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ std::string ModSecurityTest<T>::header() {
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool ModSecurityTest<T>::load_test_json(std::string file) {
|
bool ModSecurityTest<T>::load_test_json(std::string file) {
|
||||||
std::vector<yajl_val> tests;
|
|
||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
yajl_val node;
|
yajl_val node;
|
||||||
|
|
||||||
@ -128,9 +127,8 @@ std::pair<std::string, std::vector<T *>>* ModSecurityTest<T>::load_tests() {
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ModSecurityTest<T>::cmd_options(int argc, char **argv) {
|
void ModSecurityTest<T>::cmd_options(int argc, char **argv) {
|
||||||
int option_char;
|
|
||||||
|
|
||||||
#if HAS_GETOPT
|
#if HAS_GETOPT
|
||||||
|
int option_char;
|
||||||
GetOpt getopt(argc, argv, "hvct:");
|
GetOpt getopt(argc, argv, "hvct:");
|
||||||
|
|
||||||
while ((option_char = getopt()) != EOF) {
|
while ((option_char = getopt()) != EOF) {
|
||||||
|
@ -58,13 +58,12 @@ void print_help() {
|
|||||||
|
|
||||||
void perform_unit_test(UnitTest *t, ModSecurityTestResults<UnitTest>* res) {
|
void perform_unit_test(UnitTest *t, ModSecurityTestResults<UnitTest>* res) {
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (t->type == "op") {
|
if (t->type == "op") {
|
||||||
Operator *op = Operator::instantiate("\"@" + t->name + \
|
Operator *op = Operator::instantiate("\"@" + t->name + \
|
||||||
" " + t->param + "\"");
|
" " + t->param + "\"");
|
||||||
op->init(&error);
|
op->init(&error);
|
||||||
ret = op->evaluate(NULL, t->input);
|
int ret = op->evaluate(NULL, t->input);
|
||||||
if (ret != t->ret) {
|
if (ret != t->ret) {
|
||||||
t->obtained = ret;
|
t->obtained = ret;
|
||||||
res->push_back(t);
|
res->push_back(t);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user