Moves RuleMessage to its own file

This commit is contained in:
Felipe Zimmerle
2016-11-04 11:57:15 -03:00
parent ac4cb53d09
commit 768cc74f0e
11 changed files with 157 additions and 82 deletions

View File

@@ -97,87 +97,6 @@ class Rule {
int m_referenceCount;
};
class RuleMessage {
public:
explicit RuleMessage(Rule *rule) :
m_ruleFile(rule->m_fileName),
m_ruleLine(rule->m_lineNumber),
m_ruleId(rule->rule_id),
m_rev(rule->m_rev),
m_accuracy(rule->m_accuracy),
m_message(std::string("")),
m_data(std::string("")),
m_severity(0),
m_ver(rule->m_ver),
m_maturity(rule->m_maturity),
m_rule(rule),
m_saveMessage(false),
m_match(std::string(""))
{ }
RuleMessage(Rule *rule, std::string message) :
m_ruleFile(rule->m_fileName),
m_ruleLine(rule->m_lineNumber),
m_ruleId(rule->rule_id),
m_rev(rule->m_rev),
m_accuracy(rule->m_accuracy),
m_message(message),
m_data(std::string("")),
m_severity(0),
m_ver(rule->m_ver),
m_maturity(rule->m_maturity),
m_rule(rule),
m_saveMessage(false),
m_match(std::string(""))
{ }
std::string errorLog(Transaction *trans) {
std::string msg;
msg.append("[client " + std::string(trans->m_clientIpAddress) + "]");
msg.append(" ModSecurity: Warning. ");
msg.append(m_match);
msg.append(" [file \"" + std::string(m_ruleFile) + "\"]");
msg.append(" [line \"" + std::to_string(m_ruleLine) + "\"]");
msg.append(" [id \"" + std::to_string(m_ruleId) + "\"]");
msg.append(" [rev \"" + m_rev + "\"]");
msg.append(" [msg \"" + m_message + "\"]");
msg.append(" [data \"" + m_data + "\"]");
msg.append(" [severity \"" +
std::to_string(m_severity) + "\"]");
msg.append(" [ver \"" + m_ver + "\"]");
msg.append(" [maturity \"" + std::to_string(m_maturity) + "\"]");
msg.append(" [accuracy \"" + std::to_string(m_accuracy) + "\"]");
for (auto &a : m_tags) {
msg.append(" [tag \"" + a + "\"]");
}
msg.append(" [hostname \"" + std::string(trans->m_serverIpAddress) \
+ "\"]");
msg.append(" [uri \"" + std::string(trans->m_uri) + "\"]");
msg.append(" [unique_id \"" + trans->m_id + "\"]");
return msg;
}
std::string m_match;
std::string m_ruleFile;
int m_ruleLine;
int m_ruleId;
std::string m_message;
std::string m_data;
int m_severity;
std::string m_ver;
std::string m_rev;
int m_maturity;
int m_accuracy;
std::list<std::string> m_tags;
Rule *m_rule;
bool m_saveMessage;
};
} // namespace modsecurity
#endif