Cosmetics: Reduce the coding style warnings

This commit is contained in:
Felipe Zimmerle 2016-03-21 15:32:02 -03:00
parent c43391072c
commit 214cc15785
7 changed files with 22 additions and 25 deletions

View File

@ -17,6 +17,7 @@
#include <stack> #include <stack>
#include <vector> #include <vector>
#include <string> #include <string>
#include <list>
#endif #endif
#ifndef HEADERS_MODSECURITY_RULE_H_ #ifndef HEADERS_MODSECURITY_RULE_H_
@ -90,7 +91,7 @@ class Rule {
class RuleMessage { class RuleMessage {
public: public:
RuleMessage(Rule *rule) : explicit RuleMessage(Rule *rule) :
m_ruleFile(rule->m_fileName), m_ruleFile(rule->m_fileName),
m_ruleLine(rule->m_lineNumber), m_ruleLine(rule->m_lineNumber),
m_ruleId(rule->rule_id), m_ruleId(rule->rule_id),

View File

@ -47,28 +47,21 @@ namespace transaction {
* We have to have a better hash function, maybe based on the std::hash. * We have to have a better hash function, maybe based on the std::hash.
* *
*/ */
struct MyEqual struct MyEqual {
{ bool operator()(const std::string& Left, const std::string& Right) const {
bool operator()(const std::string& Left, const std::string& Right) const
{
return Left.size() == Right.size() return Left.size() == Right.size()
&& std::equal(Left.begin(), Left.end(), Right.begin(), && std::equal(Left.begin(), Left.end(), Right.begin(),
[]( char a , char b ) [](char a, char b) {
{
return tolower(a) == tolower(b); return tolower(a) == tolower(b);
} });
);
} }
}; };
struct MyHash struct MyHash{
{ size_t operator()(const std::string& Keyval) const {
size_t operator()(const std::string& Keyval) const
{
// You might need a better hash function than this // You might need a better hash function than this
size_t h = 0; 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); h += tolower(c);
}); });
return h; return h;
@ -92,14 +85,12 @@ class Variables :
std::string* resolveFirst(const std::string& var); std::string* resolveFirst(const std::string& var);
void resolveSingleMatch(const std::string& var, void resolveSingleMatch(const std::string& var,
std::vector<const transaction::Variable *> *l); std::vector<const transaction::Variable *> *l);
void resolveMultiMatches(const std::string& var, void resolveMultiMatches(const std::string& var,
std::vector<const transaction::Variable *> *l); std::vector<const transaction::Variable *> *l);
void resolveRegularExpression(const std::string& var, void resolveRegularExpression(const std::string& var,
std::vector<const transaction::Variable *> *l); std::vector<const transaction::Variable *> *l);
}; };
} // namespace transaction } // namespace transaction

View File

@ -31,7 +31,8 @@ class LogData : public Action {
public: public:
explicit LogData(std::string action); explicit LogData(std::string action);
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override; bool evaluate(Rule *rule, Transaction *transaction,
RuleMessage *rm) override;
private: private:
std::string m_data; std::string m_data;

View File

@ -31,7 +31,8 @@ class Tag : public Action {
public: public:
explicit Tag(std::string action); explicit Tag(std::string action);
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override; bool evaluate(Rule *rule, Transaction *transaction,
RuleMessage *rm) override;
private: private:
std::string m_tag; std::string m_tag;

View File

@ -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; ruleMessage->m_data = m_log_data;
trasn->m_rulesMessages.push_back(ruleMessage); trasn->m_rulesMessages.push_back(ruleMessage);
} else { } else {

View File

@ -1195,7 +1195,8 @@ int Transaction::processLogging(int returned_code) {
#endif #endif
std::list<std::pair<int, std::string>>::iterator it; std::list<std::pair<int, std::string>>::iterator it;
parts = this->m_rules->audit_log->m_parts; 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(); for (it = m_auditLogModifier.begin();
it != m_auditLogModifier.end(); ++it) { it != m_auditLogModifier.end(); ++it) {
std::pair <int, std::string> p = *it; std::pair <int, std::string> p = *it;
@ -1219,7 +1220,8 @@ int Transaction::processLogging(int returned_code) {
bool saved = this->m_rules->audit_log->saveIfRelevant(this, parts); bool saved = this->m_rules->audit_log->saveIfRelevant(this, parts);
if (saved) { if (saved) {
#ifndef NO_LOGS #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 #endif
} }
} }