From 4cf6c714ac40b8ef70931bb6ad9f079c1349ad94 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Tue, 12 Jul 2016 21:39:37 -0300 Subject: [PATCH] Cosmetics: Fix coding style --- headers/modsecurity/collection/collection.h | 2 +- headers/modsecurity/rules_properties.h | 2 +- headers/modsecurity/transaction.h | 2 +- src/actions/action.h | 2 -- src/actions/allow.cc | 3 +- src/actions/allow.h | 4 +-- src/actions/init_col.cc | 6 ++-- src/actions/transformations/base64_decode.h | 2 +- src/actions/transformations/base64_encode.h | 2 +- src/actions/transformations/cmd_line.cc | 2 +- src/actions/transformations/cmd_line.h | 1 + .../transformations/remove_comments_char.cc | 10 +++--- src/audit_log/writer/https.h | 1 - .../backend/in_memory-per_process.cc | 3 +- src/collection/backend/lmdb.cc | 6 ++-- src/operators/operator.h | 1 + src/operators/pm_from_file.cc | 2 +- src/request_body_processor/multipart.cc | 8 ++--- src/request_body_processor/multipart.h | 2 +- src/transaction.cc | 13 +++++--- src/utils.cc | 2 +- src/utils/base64.cc | 20 ++++++----- src/utils/base64.h | 33 +++++++++++++++---- src/utils/regex.h | 2 +- src/utils/sha1.cc | 8 ++--- src/utils/sha1.h | 4 +-- src/variables/remote_user.h | 3 +- src/variables/rule.cc | 3 +- src/variables/rule.h | 2 +- src/variables/variable.cc | 6 ++-- test/common/modsecurity_test.cc | 2 +- test/regression/regression.cc | 7 ++-- test/unit/unit.cc | 5 ++- test/unit/unit_test.cc | 7 ++-- 34 files changed, 109 insertions(+), 69 deletions(-) diff --git a/headers/modsecurity/collection/collection.h b/headers/modsecurity/collection/collection.h index a89ad984..3e96fca4 100644 --- a/headers/modsecurity/collection/collection.h +++ b/headers/modsecurity/collection/collection.h @@ -39,7 +39,7 @@ namespace collection { class Collection { public: - virtual ~Collection() { }; + virtual ~Collection() { } virtual void store(std::string key, std::string value) = 0; virtual bool storeOrUpdateFirst(const std::string &key, diff --git a/headers/modsecurity/rules_properties.h b/headers/modsecurity/rules_properties.h index 7f26a0c2..7e7fb10a 100644 --- a/headers/modsecurity/rules_properties.h +++ b/headers/modsecurity/rules_properties.h @@ -103,7 +103,7 @@ class RulesProperties { */ ~RulesProperties() { delete m_debugLog; - }; + } std::vector rules[7]; std::vector * getRulesForPhase(int phase) { diff --git a/headers/modsecurity/transaction.h b/headers/modsecurity/transaction.h index 5b40b3b7..d5f0d23b 100644 --- a/headers/modsecurity/transaction.h +++ b/headers/modsecurity/transaction.h @@ -73,7 +73,7 @@ class Rules; class RuleMessage; namespace actions { class Action; -enum AllowType : short; +enum AllowType : int; } namespace RequestBodyProcessor { class XML; diff --git a/src/actions/action.h b/src/actions/action.h index 3057ca8c..233b413f 100644 --- a/src/actions/action.h +++ b/src/actions/action.h @@ -124,8 +124,6 @@ class Action { */ RunTimeOnlyIfMatchKind, }; - - }; diff --git a/src/actions/allow.cc b/src/actions/allow.cc index 4938d9df..ba5daff1 100644 --- a/src/actions/allow.cc +++ b/src/actions/allow.cc @@ -36,7 +36,8 @@ bool Allow::init(std::string *error) { } else if (a == "") { m_allowType = FromNowOneAllowType; } else { - error->assign("Allow: if specified, the parameter most be: phase, request"); + error->assign("Allow: if specified, the parameter " \ + "most be: phase, request"); return false; } diff --git a/src/actions/allow.h b/src/actions/allow.h index e8ac4ac3..6cbb8e89 100644 --- a/src/actions/allow.h +++ b/src/actions/allow.h @@ -29,7 +29,7 @@ class Rule; namespace actions { -enum AllowType : short { +enum AllowType : int { /** * */ @@ -61,7 +61,7 @@ class Allow : public Action { AllowType m_allowType; - static std::string allowTypeToName (AllowType a) { + static std::string allowTypeToName(AllowType a) { if (a == NoneAllowType) { return "None"; } else if (a == RequestAllowType) { diff --git a/src/actions/init_col.cc b/src/actions/init_col.cc index d381f934..cf59d8af 100644 --- a/src/actions/init_col.cc +++ b/src/actions/init_col.cc @@ -36,7 +36,8 @@ bool InitCol::init(std::string *error) { return false; } if (posEquals == std::string::npos) { - error->assign("Something wrong with initcol format: missing equals sign"); + error->assign("Something wrong with initcol format: missing " \ + "equals sign"); return false; } @@ -46,7 +47,8 @@ bool InitCol::init(std::string *error) { if (m_collection_key != "ip" && m_collection_key != "global" && m_collection_key != "resource") { - error->assign("Something wrong with initcol: collection must be `ip' or `global'"); + error->assign("Something wrong with initcol: collection must be " \ + "`ip' or `global'"); return false; } diff --git a/src/actions/transformations/base64_decode.h b/src/actions/transformations/base64_decode.h index e91d6898..002b6cc2 100644 --- a/src/actions/transformations/base64_decode.h +++ b/src/actions/transformations/base64_decode.h @@ -30,7 +30,7 @@ namespace transformations { class Base64Decode : public Transformation { public: - explicit Base64Decode(std::string action) : Transformation(action) { }; + explicit Base64Decode(std::string action) : Transformation(action) { } std::string evaluate(std::string exp, Transaction *transaction) override; diff --git a/src/actions/transformations/base64_encode.h b/src/actions/transformations/base64_encode.h index 0d47e7ad..41c93f4b 100644 --- a/src/actions/transformations/base64_encode.h +++ b/src/actions/transformations/base64_encode.h @@ -30,7 +30,7 @@ namespace transformations { class Base64Encode : public Transformation { public: - explicit Base64Encode(std::string action) : Transformation(action) { }; + explicit Base64Encode(std::string action) : Transformation(action) { } std::string evaluate(std::string exp, Transaction *transaction) override; diff --git a/src/actions/transformations/cmd_line.cc b/src/actions/transformations/cmd_line.cc index 96b79876..38f3105d 100644 --- a/src/actions/transformations/cmd_line.cc +++ b/src/actions/transformations/cmd_line.cc @@ -43,7 +43,6 @@ std::string CmdLine::evaluate(std::string value, case '\'': case '\\': case '^': - //ret.append("i was here"); break; /* replace some characters to space (only one) */ @@ -85,3 +84,4 @@ std::string CmdLine::evaluate(std::string value, } // namespace transformations } // namespace actions } // namespace modsecurity + diff --git a/src/actions/transformations/cmd_line.h b/src/actions/transformations/cmd_line.h index a6be5f87..a38685ed 100644 --- a/src/actions/transformations/cmd_line.h +++ b/src/actions/transformations/cmd_line.h @@ -44,3 +44,4 @@ class CmdLine : public Transformation { #endif #endif // SRC_ACTIONS_TRANSFORMATIONS_CMD_LINE_H_ + diff --git a/src/actions/transformations/remove_comments_char.cc b/src/actions/transformations/remove_comments_char.cc index 7feaf87a..1a267029 100644 --- a/src/actions/transformations/remove_comments_char.cc +++ b/src/actions/transformations/remove_comments_char.cc @@ -54,12 +54,13 @@ std::string RemoveCommentsChar::evaluate(std::string value, && value.at(i+2) == '-' && (i+3 < value.size()) && value.at(i+3) == '-') { - value.erase(i, 4); - } else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-' && - (i+2 < value.size()) && value.at(i+2) == '>') { + } else if (value.at(i) == '-' + && (i+1 < value.size()) && value.at(i+1) == '-' + && (i+2 < value.size()) && value.at(i+2) == '>') { value.erase(i, 3); - } else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-') { + } else if (value.at(i) == '-' + && (i+1 < value.size()) && value.at(i+1) == '-') { value.erase(i, 2); } else if (value.at(i) == '#') { value.erase(i, 1); @@ -73,3 +74,4 @@ std::string RemoveCommentsChar::evaluate(std::string value, } // namespace transformations } // namespace actions } // namespace modsecurity + diff --git a/src/audit_log/writer/https.h b/src/audit_log/writer/https.h index 4011c6b8..431dbe4c 100644 --- a/src/audit_log/writer/https.h +++ b/src/audit_log/writer/https.h @@ -53,7 +53,6 @@ class Https : public audit_log::Writer { bool init() override; bool write(Transaction *transaction, int parts) override; - }; } // namespace writer diff --git a/src/collection/backend/in_memory-per_process.cc b/src/collection/backend/in_memory-per_process.cc index de512e60..b2cea9ba 100644 --- a/src/collection/backend/in_memory-per_process.cc +++ b/src/collection/backend/in_memory-per_process.cc @@ -117,7 +117,8 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var, return; } std::string col = std::string(var, 0, var.find(":")); - std::string name = std::string(var, var.find(":") + 2, var.size() - var.find(":") - 3); + std::string name = std::string(var, var.find(":") + 2, + var.size() - var.find(":") - 3); size_t keySize = col.size(); Utils::Regex r = Utils::Regex(name); diff --git a/src/collection/backend/lmdb.cc b/src/collection/backend/lmdb.cc index fff6153e..d327e750 100644 --- a/src/collection/backend/lmdb.cc +++ b/src/collection/backend/lmdb.cc @@ -35,7 +35,8 @@ namespace backend { LMDB::LMDB() : m_env(NULL) { mdb_env_create(&m_env); - mdb_env_open(m_env, "./modsec-shared-collections", MDB_WRITEMAP | MDB_NOSUBDIR, 0664); + mdb_env_open(m_env, "./modsec-shared-collections", + MDB_WRITEMAP | MDB_NOSUBDIR, 0664); } @@ -46,9 +47,10 @@ LMDB::~LMDB() { void LMDB::string2val(const std::string& str, MDB_val *val) { val->mv_size = sizeof(char)*(str.size()); - val->mv_data = (char *)str.c_str(); + val->mv_data = const_cast(str.c_str()); } + void LMDB::lmdb_debug(int rc, std::string op, std::string scope) { #ifndef LMDB_STDOUT_COUT return; diff --git a/src/operators/operator.h b/src/operators/operator.h index 72e44f34..ae267f44 100644 --- a/src/operators/operator.h +++ b/src/operators/operator.h @@ -49,6 +49,7 @@ class Operator { virtual bool evaluate(Transaction *transaction, const std::string &str); static Operator *instantiate(std::string op); + protected: bool debug(Transaction *transaction, int x, std::string a); }; diff --git a/src/operators/pm_from_file.cc b/src/operators/pm_from_file.cc index 4aac167c..d6863e7d 100644 --- a/src/operators/pm_from_file.cc +++ b/src/operators/pm_from_file.cc @@ -51,7 +51,7 @@ bool PmFromFile::init(const std::string &config, std::string *error) { acmp_add_pattern(m_p, line.c_str(), NULL, NULL, line.length()); } - //acmp_prepare(m_p); + // acmp_prepare(m_p); delete iss; return true; diff --git a/src/request_body_processor/multipart.cc b/src/request_body_processor/multipart.cc index 35a74125..2c6d0fac 100644 --- a/src/request_body_processor/multipart.cc +++ b/src/request_body_processor/multipart.cc @@ -102,7 +102,6 @@ Multipart::~Multipart() { delete m_mpp; m_mpp = NULL; } - } @@ -627,7 +626,8 @@ int Multipart::process_part_header(std::string *error) { if (m_mpp->m_headers.count("Content-Disposition") == 0) { debug(1, "Multipart: Part missing Content-Disposition header."); - error->assign("Multipart: Part missing Content-Disposition header."); + error->assign("Multipart: Part missing " \ + "Content-Disposition header."); return false; } header_value = m_mpp->m_headers.at("Content-Disposition"); @@ -737,8 +737,8 @@ int Multipart::process_part_header(std::string *error) { if (*data == '\0') { debug(1, "Multipart: Invalid part header (colon missing): " \ + std::string(m_buf)); - error->assign("Multipart: Invalid part header (colon missing): " \ - + std::string(m_buf)); + error->assign("Multipart: Invalid part header " \ + "(colon missing): " + std::string(m_buf)); return false; } diff --git a/src/request_body_processor/multipart.h b/src/request_body_processor/multipart.h index 9db0a799..7818625d 100644 --- a/src/request_body_processor/multipart.h +++ b/src/request_body_processor/multipart.h @@ -61,7 +61,7 @@ class MultipartPart { m_offset(0), m_length(0) { } - ~MultipartPart () { + ~MultipartPart() { m_headers.clear(); m_value_parts.clear(); } diff --git a/src/transaction.cc b/src/transaction.cc index f4de863f..8fe9e940 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -268,21 +268,24 @@ bool Transaction::extractArguments(const std::string &orig, key_s = (key.length() + 1); value_s = (value.length() + 1); - unsigned char *key_c = (unsigned char *) calloc(sizeof(char), key_s); - unsigned char *value_c = (unsigned char *) calloc(sizeof(char), value_s); + unsigned char *key_c = reinterpret_cast( + calloc(sizeof(char), key_s)); + unsigned char *value_c = reinterpret_cast( + calloc(sizeof(char), value_s)); memcpy(key_c, key.c_str(), key_s); memcpy(value_c, value.c_str(), value_s); key_s = urldecode_nonstrict_inplace(key_c, key_s, &invalid, &changed); - value_s = urldecode_nonstrict_inplace(value_c, value_s, &invalid, &changed); + value_s = urldecode_nonstrict_inplace(value_c, value_s, + &invalid, &changed); if (invalid) { m_collections.storeOrUpdateFirst("URLENCODED_ERROR", "1"); } - addArgument(orig, std::string((char *)key_c, key_s-1), - std::string((char *)value_c, value_s-1)); + addArgument(orig, std::string(reinterpret_cast(key_c), key_s-1), + std::string(reinterpret_cast(value_c), value_s-1)); free(key_c); free(value_c); diff --git a/src/utils.cc b/src/utils.cc index daa2f229..323ed879 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -134,7 +134,7 @@ int urldecode_nonstrict_inplace(unsigned char *input, std::string removeBracketsIfNeeded(std::string a) { - if ((a.at(0) == '"') and (a.at(a.length()-1) == '"')) { + if ((a.at(0) == '"') && (a.at(a.length()-1) == '"')) { a.pop_back(); a.erase(0, 1); } diff --git a/src/utils/base64.cc b/src/utils/base64.cc index ce57d690..b011015f 100644 --- a/src/utils/base64.cc +++ b/src/utils/base64.cc @@ -13,19 +13,21 @@ * */ +#include "utils/base64.h" + +#include + #include #include #include -#include "utils/base64.h" #include "mbedtls/base64.h" -#include namespace modsecurity { namespace Utils { -std::string Base64::encode(std::string& data) { +std::string Base64::encode(const std::string& data) { size_t encoded_len = 0; unsigned char *d = NULL; std::string ret; @@ -51,7 +53,7 @@ std::string Base64::encode(std::string& data) { } -std::string Base64::decode(std::string& data, bool forgiven) { +std::string Base64::decode(const std::string& data, bool forgiven) { if (forgiven) { return decode_forgiven(data); } @@ -60,7 +62,7 @@ std::string Base64::decode(std::string& data, bool forgiven) { } -std::string Base64::decode(std::string& data) { +std::string Base64::decode(const std::string& data) { size_t decoded_len = 0; unsigned char *d = NULL; std::string ret; @@ -86,7 +88,7 @@ std::string Base64::decode(std::string& data) { } -std::string Base64::decode_forgiven(std::string& data) { +std::string Base64::decode_forgiven(const std::string& data) { size_t decoded_len = 0; unsigned char *d = NULL; std::string ret; @@ -117,7 +119,7 @@ void Base64::decode_forgiven_engine(unsigned char *plain_text, int i = 0, j = 0, k = 0; int ch = 0; static const char b64_pad = '='; - static short b64_reverse_t[256] = { + static int b64_reverse_t[256] = { -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -2, -2, -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63, @@ -154,7 +156,7 @@ void Base64::decode_forgiven_engine(unsigned char *plain_text, *aiming_size = 0; return; } - switch(i % 4) { + switch (i % 4) { case 0: if (plain_text_size != 0) { plain_text[j] = ch << 2; @@ -189,7 +191,7 @@ void Base64::decode_forgiven_engine(unsigned char *plain_text, k = j; if (ch == b64_pad) { - switch(i % 4) { + switch (i % 4) { case 1: *aiming_size = 0; return; diff --git a/src/utils/base64.h b/src/utils/base64.h index 265785b5..ab63449e 100644 --- a/src/utils/base64.h +++ b/src/utils/base64.h @@ -1,5 +1,24 @@ +/* + * ModSecurity, http://www.modsecurity.org/ + * Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/) + * + * You may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * If any of the files related to licensing are missing or if you have any + * other questions related to licensing please contact Trustwave Holdings, Inc. + * directly using the email address security@modsecurity.org. + * + */ +#ifndef SRC_UTILS_BASE64_H_ +#define SRC_UTILS_BASE64_H_ + +#include + namespace modsecurity { namespace Utils { @@ -7,18 +26,20 @@ class Base64 { public: Base64() { } - static std::string encode(std::string& data); + static std::string encode(const std::string& data); - static std::string decode(std::string& data, bool forgiven); - static std::string decode(std::string& data); - static std::string decode_forgiven(std::string& data); + static std::string decode(const std::string& data, bool forgiven); + static std::string decode(const std::string& data); + static std::string decode_forgiven(const std::string& data); static void decode_forgiven_engine(unsigned char *output, size_t output_size, size_t *aiming_size, const unsigned char *input, size_t input_size); - }; } // namespace Utils -} // namespace modsecurity \ No newline at end of file +} // namespace modsecurity + +#endif // SRC_UTILS_BASE64_H_ + diff --git a/src/utils/regex.h b/src/utils/regex.h index 5a0e0044..45405b1e 100644 --- a/src/utils/regex.h +++ b/src/utils/regex.h @@ -43,7 +43,7 @@ class SMatch { public: SMatch() : size_(0) { } size_t size() const { return size_; } - std::string str() const { return match; } + std::string str() const { return match; } int size_; std::string match; }; diff --git a/src/utils/sha1.cc b/src/utils/sha1.cc index 78ec4792..7193eae1 100644 --- a/src/utils/sha1.cc +++ b/src/utils/sha1.cc @@ -21,15 +21,15 @@ namespace modsecurity { namespace Utils { -std::string Sha1::hexdigest(std::string& input) { +std::string Sha1::hexdigest(const std::string& input) { unsigned char digest[20]; mbedtls_sha1(reinterpret_cast(input.c_str()), input.size(), digest); char buf[41]; - for (int i=0; i<20; i++) { - sprintf(buf+i*2, "%02x", digest[i]); + for (int i=0; i < 20; i++) { + snprintf(buf+i*2, sizeof(char)*2, "%02x", digest[i]); } buf[40] = 0; @@ -37,7 +37,7 @@ std::string Sha1::hexdigest(std::string& input) { } -std::string Sha1::digest(std::string& input) { +std::string Sha1::digest(const std::string& input) { unsigned char output[20]; std::string ret; diff --git a/src/utils/sha1.h b/src/utils/sha1.h index e44a5b81..0167c35f 100644 --- a/src/utils/sha1.h +++ b/src/utils/sha1.h @@ -28,8 +28,8 @@ class Sha1 { public: Sha1() { } - static std::string hexdigest(std::string& input); - static std::string digest(std::string& input); + static std::string hexdigest(const std::string& input); + static std::string digest(const std::string& input); }; } // namespace Utils diff --git a/src/variables/remote_user.h b/src/variables/remote_user.h index 8a969761..8f6c78c3 100644 --- a/src/variables/remote_user.h +++ b/src/variables/remote_user.h @@ -43,4 +43,5 @@ class RemoteUser : public Variable { } // namespace Variables } // namespace modsecurity -#endif // SRC_VARIABLES_REMOTE_USER_H_ \ No newline at end of file +#endif // SRC_VARIABLES_REMOTE_USER_H_ + diff --git a/src/variables/rule.cc b/src/variables/rule.cc index 76e2ad11..4c2de01c 100644 --- a/src/variables/rule.cc +++ b/src/variables/rule.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include "modsecurity/transaction.h" #include "modsecurity/rules_properties.h" @@ -54,7 +55,7 @@ void Rule::evaluateInternal(Transaction *t, // id envs.insert(std::pair("RULE:id", - std::to_string(rule->rule_id))); + std::to_string(rule->rule_id))); // rev envs.insert(std::pair("RULE:rev", diff --git a/src/variables/rule.h b/src/variables/rule.h index 0e2f99b6..f39d6b7c 100644 --- a/src/variables/rule.h +++ b/src/variables/rule.h @@ -30,7 +30,7 @@ namespace Variables { class Rule : public Variable { public: explicit Rule(std::string _name) - : Variable(_name) { }; + : Variable(_name) { } void evaluateInternal(Transaction *transaction, modsecurity::Rule *rule, diff --git a/src/variables/variable.cc b/src/variables/variable.cc index 54804fc6..ae35f13e 100644 --- a/src/variables/variable.cc +++ b/src/variables/variable.cc @@ -37,7 +37,8 @@ Variable::Variable(std::string name) m_isCount(false) { if (m_name.find(":") != std::string::npos) { std::string col = toupper(std::string(m_name, 0, m_name.find(":"))); - std::string name = std::string(m_name, m_name.find(":") + 1, m_name.size()); + std::string name = std::string(m_name, m_name.find(":") + 1, + m_name.size()); if (col == "TX" || col == "IP" || col == "GLOBAL" || col == "RESOURCE" || col == "SESSION") { m_collectionName = col; @@ -83,7 +84,8 @@ Variable::Variable(std::string name, VariableKind kind) m_isCount(false) { if (m_name.find(":") != std::string::npos) { std::string col = toupper(std::string(m_name, 0, m_name.find(":"))); - std::string name = std::string(m_name, m_name.find(":") + 1, m_name.size()); + std::string name = std::string(m_name, m_name.find(":") + 1, + m_name.size()); if (col == "TX" || col == "IP" || col == "GLOBAL" || col == "RESOURCE" || col == "SESSION") { m_collectionName = col; diff --git a/test/common/modsecurity_test.cc b/test/common/modsecurity_test.cc index ea9c7907..9e2f7bf7 100644 --- a/test/common/modsecurity_test.cc +++ b/test/common/modsecurity_test.cc @@ -142,7 +142,7 @@ void ModSecurityTest::cmd_options(int argc, char **argv) { m_automake_output = true; } - if(const char* env_p = std::getenv("AUTOMAKE_TESTS")) { + if (const char* env_p = std::getenv("AUTOMAKE_TESTS")) { m_automake_output = true; } diff --git a/test/regression/regression.cc b/test/regression/regression.cc index e6cdd4e1..fb1374a7 100644 --- a/test/regression/regression.cc +++ b/test/regression/regression.cc @@ -270,9 +270,11 @@ void perform_unit_test(ModSecurityTest *test, modsec_transaction->processRequestHeaders(); actions(&r, modsec_transaction); +#if 0 if (r.status != 200) { - //goto end; + goto end; } +#endif modsec_transaction->appendRequestBody( (unsigned char *)t->request_body.c_str(), @@ -291,7 +293,8 @@ void perform_unit_test(ModSecurityTest *test, headers.second.c_str()); } - modsec_transaction->processResponseHeaders(r.status, t->response_protocol); + modsec_transaction->processResponseHeaders(r.status, + t->response_protocol); actions(&r, modsec_transaction); #if 0 if (r.status != 200) { diff --git a/test/unit/unit.cc b/test/unit/unit.cc index 00f7d594..558b7d07 100644 --- a/test/unit/unit.cc +++ b/test/unit/unit.cc @@ -91,7 +91,6 @@ void perform_unit_test(ModSecurityTest *test, UnitTest *t, std::cout << t->name << " " << modsecurity::toHexIfNeeded(t->input) << std::endl; } - } @@ -150,9 +149,9 @@ int main(int argc, char **argv) { if (results.size() == 0) { std::cout << KGRN << "All tests passed" << RESET << std::endl; } else { - std::cout << KRED << results.size() << " failed." << RESET << std::endl; + std::cout << KRED << results.size() << " failed."; + std::cout << RESET << std::endl; } - } for (std::pair *> a : test) { diff --git a/test/unit/unit_test.cc b/test/unit/unit_test.cc index 5bb7d85b..02e63f0e 100644 --- a/test/unit/unit_test.cc +++ b/test/unit/unit_test.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include "common/colors.h" #include "src/utils.h" @@ -62,7 +61,8 @@ void json2bin(std::string *str) { modsecurity::Utils::Regex re2("\\\\u([a-z0-9A-Z]{4})"); modsecurity::Utils::SMatch match; - while (modsecurity::Utils::regex_search(*str, &match, re) && match.size() > 0) { + while (modsecurity::Utils::regex_search(*str, &match, re) + && match.size() > 0) { unsigned int p; std::string toBeReplaced = match.str(); toBeReplaced.erase(0, 2); @@ -70,7 +70,8 @@ void json2bin(std::string *str) { replaceAll(str, match.str(), p); } - while (modsecurity::Utils::regex_search(*str, &match, re2) && match.size() > 0) { + while (modsecurity::Utils::regex_search(*str, &match, re2) + && match.size() > 0) { unsigned int p; std::string toBeReplaced = match.str(); toBeReplaced.erase(0, 2);