diff --git a/headers/modsecurity/rule.h b/headers/modsecurity/rule.h index cd856aeb..64e650ad 100644 --- a/headers/modsecurity/rule.h +++ b/headers/modsecurity/rule.h @@ -17,6 +17,7 @@ #include #include #include +#include #endif #ifndef HEADERS_MODSECURITY_RULE_H_ @@ -90,7 +91,7 @@ class Rule { class RuleMessage { public: - RuleMessage(Rule *rule) : + explicit RuleMessage(Rule *rule) : m_ruleFile(rule->m_fileName), m_ruleLine(rule->m_lineNumber), m_ruleId(rule->rule_id), diff --git a/headers/modsecurity/transaction/variables.h b/headers/modsecurity/transaction/variables.h index 21414b88..d47b7a10 100644 --- a/headers/modsecurity/transaction/variables.h +++ b/headers/modsecurity/transaction/variables.h @@ -47,28 +47,21 @@ namespace transaction { * We have to have a better hash function, maybe based on the std::hash. * */ -struct MyEqual -{ - bool operator()(const std::string& Left, const std::string& Right) const - { +struct MyEqual { + bool operator()(const std::string& Left, const std::string& Right) const { return Left.size() == Right.size() - && std::equal ( Left.begin() , Left.end() , Right.begin(), - []( char a , char b ) - { + && std::equal(Left.begin(), Left.end(), Right.begin(), + [](char a, char b) { return tolower(a) == tolower(b); - } - ); + }); } }; -struct MyHash -{ - size_t operator()(const std::string& Keyval) const - { - //You might need a better hash function than this +struct MyHash{ + size_t operator()(const std::string& Keyval) const { + // You might need a better hash function than this size_t h = 0; - std::for_each( Keyval.begin() , Keyval.end() , [&](char c ) - { + std::for_each(Keyval.begin(), Keyval.end(), [&](char c) { h += tolower(c); }); return h; @@ -92,14 +85,12 @@ class Variables : std::string* resolveFirst(const std::string& var); - void resolveSingleMatch(const std::string& var, std::vector *l); void resolveMultiMatches(const std::string& var, std::vector *l); void resolveRegularExpression(const std::string& var, std::vector *l); - }; } // namespace transaction diff --git a/src/actions/log_data.h b/src/actions/log_data.h index d92790e3..326dca05 100644 --- a/src/actions/log_data.h +++ b/src/actions/log_data.h @@ -31,7 +31,8 @@ class LogData : public Action { public: explicit LogData(std::string action); - bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override; + bool evaluate(Rule *rule, Transaction *transaction, + RuleMessage *rm) override; private: std::string m_data; diff --git a/src/actions/tag.h b/src/actions/tag.h index e4da0d62..ffbe5f59 100644 --- a/src/actions/tag.h +++ b/src/actions/tag.h @@ -31,7 +31,8 @@ class Tag : public Action { public: explicit Tag(std::string action); - bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override; + bool evaluate(Rule *rule, Transaction *transaction, + RuleMessage *rm) override; private: std::string m_tag; diff --git a/src/actions/transformations/html_entity_decode.cc b/src/actions/transformations/html_entity_decode.cc index 2bc1ed5a..de9d346c 100644 --- a/src/actions/transformations/html_entity_decode.cc +++ b/src/actions/transformations/html_entity_decode.cc @@ -45,7 +45,7 @@ std::string HtmlEntityDecode::evaluate(std::string value, // FIXME: html_entities_decode_inplace is not working as expected // temporary disabled to perform the audit_log tests. - //html_entities_decode_inplace((unsigned char *)tmp, value.size()); + // html_entities_decode_inplace((unsigned char *)tmp, value.size()); std::string ret(""); ret.assign(tmp); free(tmp); diff --git a/src/rule.cc b/src/rule.cc index c5d507ed..8af7f429 100644 --- a/src/rule.cc +++ b/src/rule.cc @@ -515,7 +515,8 @@ bool Rule::evaluate(Transaction *trasn) { } } - if ((!m_log_message.empty() || !m_log_data.empty()) && !ruleMessage->m_match.empty()) { + if ((!m_log_message.empty() || !m_log_data.empty()) + && !ruleMessage->m_match.empty()) { ruleMessage->m_data = m_log_data; trasn->m_rulesMessages.push_back(ruleMessage); } else { diff --git a/src/transaction.cc b/src/transaction.cc index 922fad3d..7c59cac6 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -1195,7 +1195,8 @@ int Transaction::processLogging(int returned_code) { #endif std::list>::iterator it; parts = this->m_rules->audit_log->m_parts; - debug(7, "AuditLog parts before modification(s): " + std::to_string(parts) + "."); + debug(7, "AuditLog parts before modification(s): " + + std::to_string(parts) + "."); for (it = m_auditLogModifier.begin(); it != m_auditLogModifier.end(); ++it) { std::pair p = *it; @@ -1219,7 +1220,8 @@ int Transaction::processLogging(int returned_code) { bool saved = this->m_rules->audit_log->saveIfRelevant(this, parts); if (saved) { #ifndef NO_LOGS - debug(8, "Request was relevant to be saved. Parts: " + std::to_string(parts)); + debug(8, "Request was relevant to be saved. Parts: " + + std::to_string(parts)); #endif } }