Refactoring: how to report to error logs

This commit is contained in:
Felipe Zimmerle
2016-12-01 01:05:29 -03:00
parent e6b58014db
commit bfc30dad34
29 changed files with 236 additions and 161 deletions

View File

@@ -23,6 +23,36 @@
namespace modsecurity {
std::string RuleMessage::disruptiveErrorLog(Transaction *trans, std::string msg2) {
std::string msg;
msg.append("[client " + std::string(trans->m_clientIpAddress) + "]");
msg.append(" ModSecurity: ");
msg.append(msg2);
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 \"" + trans->m_uri_no_query_string_decoded + "\"]");
msg.append(" [unique_id \"" + trans->m_id + "\"]");
return modsecurity::utils::string::toHexIfNeeded(msg);
}
std::string RuleMessage::errorLog(Transaction *trans) {
std::string msg;