mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Fix the `log' action and the webserver error callback
This commit is contained in:
@@ -102,6 +102,7 @@ ACTIONS = \
|
||||
actions/ctl_request_body_processor_xml.cc \
|
||||
actions/init_col.cc \
|
||||
actions/deny.cc \
|
||||
actions/log.cc \
|
||||
actions/log_data.cc \
|
||||
actions/maturity.cc \
|
||||
actions/msg.cc \
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "actions/severity.h"
|
||||
#include "actions/capture.h"
|
||||
#include "actions/pass.h"
|
||||
#include "actions/log.h"
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +90,9 @@ Action *Action::instantiate(const std::string& name) {
|
||||
if (name == "deny") {
|
||||
return new Deny(name);
|
||||
}
|
||||
if (name == "log") {
|
||||
return new Log(name);
|
||||
}
|
||||
return new Action(name);
|
||||
}
|
||||
|
||||
|
@@ -18,16 +18,19 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
#include "operators/operator.h"
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Log::evaluate(Rule *rule, Transaction *transaction) {
|
||||
transaction->m_toBeSavedInAuditlogs = true;
|
||||
/* FIXME: transaction->serverLog("Something...."); */
|
||||
bool Log::evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) {
|
||||
transaction->debug(9, "Saving transaction to logs");
|
||||
rm->m_saveMessage = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,8 @@ class Log : public Action {
|
||||
explicit Log(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm)
|
||||
override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
@@ -282,6 +282,7 @@ bool Rule::evaluate(Transaction *trasn) {
|
||||
}
|
||||
|
||||
ruleMessage = new modsecurity::RuleMessage(this, m_log_message);
|
||||
|
||||
#ifndef NO_LOGS
|
||||
std::string eparam = MacroExpansion::expand(this->op->param, trasn);
|
||||
|
||||
@@ -533,6 +534,10 @@ bool Rule::evaluate(Transaction *trasn) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ruleMessage->m_saveMessage == true) {
|
||||
trasn->serverLog(ruleMessage->errorLog(trasn));
|
||||
}
|
||||
|
||||
if ((!m_log_message.empty() || !m_log_data.empty())
|
||||
&& !ruleMessage->m_match.empty()) {
|
||||
ruleMessage->m_data = m_log_data;
|
||||
|
Reference in New Issue
Block a user