mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Removes RuleMessage from action execute signature
This commit is contained in:
parent
dd3801eba5
commit
710e2a7f30
@ -78,10 +78,6 @@ class Action {
|
||||
virtual std::string execute(const std::string &exp,
|
||||
Transaction *transaction);
|
||||
virtual bool execute(RuleWithActions *rule, Transaction *transaction);
|
||||
virtual bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &ruleMessage) {
|
||||
return execute(rule, transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is meant to be used by transformations — a particular
|
||||
|
@ -27,8 +27,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool AuditLog::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool AuditLog::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
transaction->messageSetNoAuditLog(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ class AuditLog : public Action {
|
||||
explicit AuditLog(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,8 +29,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Block::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Block::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 8, "Marking request as disruptive.");
|
||||
return true;
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ class Block : public Action {
|
||||
public:
|
||||
explicit Block(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -38,8 +38,7 @@ bool Status::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Status::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Status::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
transaction->m_it.status = m_status;
|
||||
return true;
|
||||
}
|
||||
|
@ -37,8 +37,7 @@ class Status : public Action {
|
||||
m_status(0) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
int m_status;
|
||||
};
|
||||
|
@ -28,8 +28,7 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
bool Deny::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Deny::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 8, "Running action deny");
|
||||
|
||||
if (transaction->m_it.status == 200) {
|
||||
@ -38,9 +37,9 @@ bool Deny::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
|
||||
transaction->m_it.disruptive = true;
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
rm.setRule(rule);
|
||||
transaction->messageGetLast()->setRule(rule);
|
||||
transaction->m_it.log = strdup(
|
||||
rm.log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
transaction->messageGetLast()->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -33,8 +33,7 @@ class Deny : public Action {
|
||||
public:
|
||||
explicit Deny(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
@ -32,8 +32,7 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
bool Drop::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Drop::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 8, "Running action drop " \
|
||||
"[executing deny instead of drop.]");
|
||||
|
||||
@ -43,9 +42,9 @@ bool Drop::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
|
||||
transaction->m_it.disruptive = true;
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
rm.setRule(rule);
|
||||
transaction->messageGetLast()->setRule(rule);
|
||||
transaction->m_it.log = strdup(
|
||||
rm.log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
transaction->messageGetLast()->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ class Drop : public Action {
|
||||
public:
|
||||
explicit Drop(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
@ -29,8 +29,7 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
bool Pass::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Pass::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
intervention::free(&transaction->m_it);
|
||||
intervention::reset(&transaction->m_it);
|
||||
|
||||
|
@ -31,8 +31,7 @@ class Pass : public Action {
|
||||
public:
|
||||
explicit Pass(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,7 @@ bool Redirect::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Redirect::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Redirect::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
std::string m_urlExpanded(m_string->evaluate(transaction));
|
||||
/* if it was changed before, lets keep it. */
|
||||
if (transaction->m_it.status == 200
|
||||
@ -47,9 +46,9 @@ bool Redirect::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
transaction->m_it.url = strdup(m_urlExpanded.c_str());
|
||||
transaction->m_it.disruptive = true;
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
rm.setRule(rule);
|
||||
transaction->messageGetLast()->setRule(rule);
|
||||
transaction->m_it.log = strdup(
|
||||
rm.log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
transaction->messageGetLast()->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ class Redirect : public Action {
|
||||
m_status(0),
|
||||
m_string(std::move(z)) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
|
||||
|
@ -28,8 +28,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Log::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Log::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ class Log : public Action {
|
||||
explicit Log(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
@ -29,9 +29,8 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool LogData::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
rm.m_data = data(transaction);
|
||||
bool LogData::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
transaction->messageGetLast()->m_data = data(transaction);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ class LogData : public Action {
|
||||
: Action("logdata", RunTimeOnlyIfMatchKind),
|
||||
m_string(std::move(z)) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
std::string data(Transaction *Transaction);
|
||||
|
||||
|
@ -46,10 +46,9 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Msg::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Msg::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
std::string msg = data(transaction);
|
||||
rm.m_message = msg;
|
||||
transaction->messageGetLast()->m_message = msg;
|
||||
ms_dbg_a(transaction, 9, "Saving msg: " + msg);
|
||||
|
||||
return true;
|
||||
|
@ -40,8 +40,7 @@ class Msg : public Action {
|
||||
: Action("msg", RunTimeOnlyIfMatchKind),
|
||||
m_string(std::move(z)) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
std::string data(Transaction *Transaction);
|
||||
std::shared_ptr<RunTimeString> m_string;
|
||||
|
@ -26,8 +26,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool NoAuditLog::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool NoAuditLog::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
transaction->messageSetNoAuditLog(true);
|
||||
return true;
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ class NoAuditLog : public Action {
|
||||
explicit NoAuditLog(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
@ -29,8 +29,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool NoLog::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool NoLog::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ class NoLog : public Action {
|
||||
explicit NoLog(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
@ -71,8 +71,7 @@ bool Severity::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Severity::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Severity::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,7 @@ class Severity : public Action {
|
||||
: Action(action),
|
||||
m_severity(0) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
int m_severity;
|
||||
|
@ -56,13 +56,11 @@ std::string Tag::getName(Transaction *transaction) {
|
||||
}
|
||||
|
||||
|
||||
bool Tag::execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) {
|
||||
bool Tag::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
std::string tag = getName(transaction);
|
||||
ms_dbg_a(transaction, 9, "Rule tag: " + tag);
|
||||
|
||||
rm.m_tags.push_back(tag);
|
||||
|
||||
transaction->messageGetLast()->m_tags.push_back(tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,7 @@ class Tag : public Action {
|
||||
|
||||
std::string getName(Transaction *transaction);
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction,
|
||||
RuleMessage &rm) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<RunTimeString> m_string;
|
||||
|
@ -258,20 +258,20 @@ void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *
|
||||
} else if (*a->m_name.get() == "setvar") {
|
||||
ms_dbg_a(trans, 4, "Running [independent] (non-disruptive) " \
|
||||
"action: " + *a->m_name.get());
|
||||
a->execute(this, trans, *trans->messageGetLast());
|
||||
a->execute(this, trans);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logData) {
|
||||
m_logData->execute(this, trans, *trans->messageGetLast());
|
||||
m_logData->execute(this, trans);
|
||||
} else if (m_defaultActionLogData) {
|
||||
m_defaultActionLogData->execute(this, trans, *trans->messageGetLast());
|
||||
m_defaultActionLogData->execute(this, trans);
|
||||
}
|
||||
|
||||
if (m_msg) {
|
||||
m_msg->execute(this, trans, *trans->messageGetLast());
|
||||
m_msg->execute(this, trans);
|
||||
} else if (m_defaultActionMsg) {
|
||||
m_defaultActionMsg->execute(this, trans, *trans->messageGetLast());
|
||||
m_defaultActionMsg->execute(this, trans);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans) {
|
||||
for (actions::Tag *a : getTagsActionPtr()) {
|
||||
ms_dbg_a(trans, 4, "Running (non-disruptive) action: " \
|
||||
+ *a->m_name.get());
|
||||
a->execute(this, trans, *trans->messageGetLast());
|
||||
a->execute(this, trans);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,11 +332,10 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans) {
|
||||
|
||||
void RuleWithActions::executeAction(Transaction *trans,
|
||||
Action *a, bool defaultContext) {
|
||||
|
||||
if (a->isDisruptive() == false && *a->m_name.get() != "block") {
|
||||
ms_dbg_a(trans, 9, "Running " \
|
||||
"action: " + *a->m_name.get());
|
||||
a->execute(this, trans, *trans->messageGetLast());
|
||||
a->execute(this, trans);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -349,7 +348,7 @@ void RuleWithActions::executeAction(Transaction *trans,
|
||||
if (trans->getRuleEngineState() == RulesSet::EnabledRuleEngine) {
|
||||
ms_dbg_a(trans, 4, "Running (disruptive) action: " +
|
||||
*a->m_name.get() + ".");
|
||||
a->execute(this, trans, *trans->messageGetLast());
|
||||
a->execute(this, trans);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user