mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-17 09:55:28 +03:00
actions: Removes Rule parameter from runtime execute
This commit is contained in:
@@ -72,8 +72,8 @@ class Action {
|
||||
|
||||
virtual std::string execute(const std::string &exp,
|
||||
Transaction *transaction);
|
||||
virtual bool execute(RuleWithActions *rule,
|
||||
Transaction *transaction);
|
||||
virtual bool execute(Transaction *transaction = nullptr);
|
||||
|
||||
/**
|
||||
* This method is meant to be used by transformations — a particular
|
||||
* type of action.
|
||||
|
||||
@@ -40,11 +40,5 @@ bool Accuracy::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Accuracy::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
rule->setAccuracy(m_accuracy);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_ACCURACY_H_
|
||||
#define SRC_ACTIONS_ACCURACY_H_
|
||||
@@ -27,15 +28,17 @@ class Transaction;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Accuracy : public Action {
|
||||
class Accuracy : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit Accuracy(const std::string &action)
|
||||
: Action(action, ConfigurationKind),
|
||||
: ActionTypeConfigure(action),
|
||||
m_accuracy(0) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
int getAccuracy() const { return m_accuracy; }
|
||||
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setAccuracy(m_accuracy);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_accuracy;
|
||||
|
||||
@@ -51,7 +51,7 @@ std::string Action::execute(const std::string &value,
|
||||
}
|
||||
|
||||
|
||||
bool Action::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Action::execute(Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool AuditLog::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool AuditLog::execute(Transaction *transaction) {
|
||||
transaction->messageSetNoAuditLog(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class AuditLog : public Action {
|
||||
explicit AuditLog(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Block::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Block::execute(Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 8, "Marking request as disruptive.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Block : public Action {
|
||||
public:
|
||||
explicit Block(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Capture::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Capture::execute(Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class Capture : public Action {
|
||||
explicit Capture(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -27,11 +27,5 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Chain::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
rule->setHasChainAction(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_CHAIN_H_
|
||||
#define SRC_ACTIONS_CHAIN_H_
|
||||
@@ -30,12 +31,15 @@ class RuleWithOperator;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Chain : public Action {
|
||||
class Chain : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit Chain(const std::string &action)
|
||||
: Action(action, ConfigurationKind) { }
|
||||
: ActionTypeConfigure(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setHasChainAction(true);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
||||
@@ -38,7 +38,7 @@ bool AuditLogParts::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AuditLogParts::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool AuditLogParts::execute(Transaction *transaction) {
|
||||
transaction->m_auditLogModifier.push_back(
|
||||
std::make_pair(mPartsAction, mParts));
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,7 @@ class AuditLogParts : public Action {
|
||||
mPartsAction(0),
|
||||
mParts("") { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -42,7 +42,7 @@ bool RequestBodyAccess::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RequestBodyAccess::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool RequestBodyAccess::execute(Transaction *transaction) {
|
||||
if (m_request_body_access) {
|
||||
transaction->m_requestBodyAccess = RulesSetProperties::TrueConfigBoolean;
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ class RequestBodyAccess : public Action {
|
||||
m_request_body_access(false) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
bool m_request_body_access;
|
||||
};
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RequestBodyProcessorJSON::execute(RuleWithActions *rule,
|
||||
Transaction *transaction) {
|
||||
bool RequestBodyProcessorJSON::execute(Transaction *transaction) {
|
||||
transaction->m_requestBodyProcessor = Transaction::JSONRequestBody;
|
||||
transaction->m_variableReqbodyProcessor.set("JSON",
|
||||
transaction->m_variableOffset);
|
||||
|
||||
@@ -31,7 +31,7 @@ class RequestBodyProcessorJSON : public Action {
|
||||
explicit RequestBodyProcessorJSON(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RequestBodyProcessorURLENCODED::execute(RuleWithActions *rule,
|
||||
Transaction *transaction) {
|
||||
bool RequestBodyProcessorURLENCODED::execute(Transaction *transaction) {
|
||||
transaction->m_requestBodyType = Transaction::WWWFormUrlEncoded;
|
||||
transaction->m_variableReqbodyProcessor.set("URLENCODED",
|
||||
transaction->m_variableOffset);
|
||||
|
||||
@@ -31,7 +31,7 @@ class RequestBodyProcessorURLENCODED : public Action {
|
||||
explicit RequestBodyProcessorURLENCODED(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RequestBodyProcessorXML::execute(RuleWithActions *rule,
|
||||
Transaction *transaction) {
|
||||
bool RequestBodyProcessorXML::execute(Transaction *transaction) {
|
||||
transaction->m_requestBodyProcessor = Transaction::XMLRequestBody;
|
||||
transaction->m_variableReqbodyProcessor.set("XML",
|
||||
transaction->m_variableOffset);
|
||||
|
||||
@@ -31,7 +31,7 @@ class RequestBodyProcessorXML : public Action {
|
||||
explicit RequestBodyProcessorXML(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ bool RuleEngine::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuleEngine::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool RuleEngine::execute(Transaction *transaction) {
|
||||
std::stringstream a;
|
||||
a << "Setting SecRuleEngine to ";
|
||||
a << modsecurity::RulesSetProperties::ruleEngineStateString(m_ruleEngine);
|
||||
|
||||
@@ -35,7 +35,7 @@ class RuleEngine : public Action {
|
||||
m_ruleEngine(RulesSetProperties::PropertyNotSetRuleEngine) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
RulesSetProperties::RuleEngine m_ruleEngine;
|
||||
};
|
||||
|
||||
@@ -83,7 +83,7 @@ bool RuleRemoveById::init(std::string *error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RuleRemoveById::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool RuleRemoveById::execute(Transaction *transaction) {
|
||||
for (auto &i : m_ids) {
|
||||
transaction->m_ruleRemoveById.push_back(i);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class RuleRemoveById : public Action {
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
std::list<std::pair<int, int> > m_ranges;
|
||||
std::list<int> m_ids;
|
||||
|
||||
@@ -32,7 +32,7 @@ bool RuleRemoveByTag::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuleRemoveByTag::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool RuleRemoveByTag::execute(Transaction *transaction) {
|
||||
transaction->m_ruleRemoveByTag.push_back(m_tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class RuleRemoveByTag : public Action {
|
||||
m_tag("") { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
std::string m_tag;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ bool RuleRemoveTargetById::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuleRemoveTargetById::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool RuleRemoveTargetById::execute(Transaction *transaction) {
|
||||
transaction->m_ruleRemoveTargetById.push_back(
|
||||
std::make_pair(m_id, m_target));
|
||||
return true;
|
||||
|
||||
@@ -35,7 +35,7 @@ class RuleRemoveTargetById : public Action {
|
||||
m_target("") { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
int m_id;
|
||||
std::string m_target;
|
||||
|
||||
@@ -44,7 +44,7 @@ bool RuleRemoveTargetByTag::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuleRemoveTargetByTag::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool RuleRemoveTargetByTag::execute(Transaction *transaction) {
|
||||
transaction->m_ruleRemoveTargetByTag.push_back(
|
||||
std::make_pair(m_tag, m_target));
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,7 @@ class RuleRemoveTargetByTag : public Action {
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
std::string m_tag;
|
||||
std::string m_target;
|
||||
|
||||
@@ -38,7 +38,7 @@ bool Status::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Status::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Status::execute(Transaction *transaction) {
|
||||
transaction->m_it.status = m_status;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class Status : public Action {
|
||||
m_status(0) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
int m_status;
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ bool Allow::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Allow::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Allow::execute(Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 4, "Dropping the evaluation of upcoming rules " \
|
||||
"in favor of an `allow' action of type: " \
|
||||
+ allowTypeToName(m_allowType));
|
||||
|
||||
@@ -59,7 +59,7 @@ class Allow : public Action {
|
||||
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
|
||||
AllowType m_allowType;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
bool Deny::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Deny::execute(Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 8, "Running action deny");
|
||||
|
||||
if (transaction->m_it.status == 200) {
|
||||
@@ -37,7 +37,7 @@ bool Deny::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
|
||||
transaction->m_it.disruptive = true;
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
transaction->messageGetLast()->setRule(rule);
|
||||
//transaction->messageGetLast()->setRule(rule);
|
||||
transaction->m_it.log = strdup(
|
||||
transaction->messageGetLast()->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Deny : public Action {
|
||||
public:
|
||||
explicit Deny(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
bool Drop::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Drop::execute(Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 8, "Running action drop " \
|
||||
"[executing deny instead of drop.]");
|
||||
|
||||
@@ -42,7 +42,7 @@ bool Drop::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
|
||||
transaction->m_it.disruptive = true;
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
transaction->messageGetLast()->setRule(rule);
|
||||
//transaction->messageGetLast()->setRule(rule);
|
||||
transaction->m_it.log = strdup(
|
||||
transaction->messageGetLast()->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class Drop : public Action {
|
||||
public:
|
||||
explicit Drop(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
bool Pass::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Pass::execute(Transaction *transaction) {
|
||||
intervention::free(&transaction->m_it);
|
||||
intervention::reset(&transaction->m_it);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class Pass : public Action {
|
||||
public:
|
||||
explicit Pass(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ bool Redirect::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Redirect::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Redirect::execute(Transaction *transaction) {
|
||||
std::string m_urlExpanded(getEvaluatedRunTimeString(transaction));
|
||||
/* if it was changed before, lets keep it. */
|
||||
if (transaction->m_it.status == 200
|
||||
@@ -46,7 +46,7 @@ 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);
|
||||
transaction->messageGetLast()->setRule(rule);
|
||||
|
||||
transaction->m_it.log = strdup(
|
||||
transaction->messageGetLast()->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class Redirect : public ActionWithRunTimeString {
|
||||
|
||||
bool init(std::string *error) override;
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
bool isDisruptive() override { return true; }
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ bool Exec::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Exec::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool Exec::execute(Transaction *t) {
|
||||
ms_dbg_a(t, 8, "Running script... " + m_script);
|
||||
m_lua.run(t);
|
||||
return true;
|
||||
|
||||
@@ -36,7 +36,7 @@ class Exec : public Action {
|
||||
|
||||
~Exec() { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -54,7 +54,7 @@ bool InitCol::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool InitCol::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool InitCol::execute(Transaction *t) {
|
||||
std::string collectionName(getEvaluatedRunTimeString(t));
|
||||
|
||||
if (m_collection_key == "ip") {
|
||||
|
||||
@@ -47,7 +47,7 @@ class InitCol : public ActionWithRunTimeString {
|
||||
|
||||
bool init(std::string *error) override;
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new InitCol(*this);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Log::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Log::execute(Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Log : public Action {
|
||||
explicit Log(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool LogData::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool LogData::execute(Transaction *transaction) {
|
||||
transaction->messageGetLast()->m_data = getEvaluatedRunTimeString(transaction);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -44,7 +44,7 @@ class LogData : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(data)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new LogData(*this);
|
||||
|
||||
@@ -40,10 +40,5 @@ bool Maturity::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Maturity::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_MATURITY_H_
|
||||
#define SRC_ACTIONS_MATURITY_H_
|
||||
@@ -27,15 +28,17 @@ class Transaction;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Maturity : public Action {
|
||||
class Maturity : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit Maturity(const std::string &action)
|
||||
: Action(action, ConfigurationKind),
|
||||
: ActionTypeConfigure(action),
|
||||
m_maturity(0) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
int getMaturity() const { return m_maturity; }
|
||||
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setMaturity(m_maturity);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_maturity;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Msg::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Msg::execute(Transaction *transaction) {
|
||||
std::string msg = getEvaluatedRunTimeString(transaction);
|
||||
transaction->messageGetLast()->m_message = msg;
|
||||
ms_dbg_a(transaction, 9, "Saving msg: " + msg);
|
||||
|
||||
@@ -45,7 +45,7 @@ class Msg : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new Msg(*this);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool MultiMatch::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool MultiMatch::execute(Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class MultiMatch : public Action {
|
||||
explicit MultiMatch(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool NoAuditLog::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool NoAuditLog::execute(Transaction *transaction) {
|
||||
transaction->messageSetNoAuditLog(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class NoAuditLog : public Action {
|
||||
explicit NoAuditLog(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool NoLog::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool NoLog::execute(Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class NoLog : public Action {
|
||||
explicit NoLog(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
||||
@@ -73,10 +73,5 @@ bool Phase::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Phase::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
rule->setPhase(m_phase);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_PHASE_H_
|
||||
#define SRC_ACTIONS_PHASE_H_
|
||||
@@ -30,14 +31,19 @@ class RuleWithOperator;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Phase : public Action {
|
||||
class Phase : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit Phase(const std::string &action) : Action(action, ConfigurationKind),
|
||||
explicit Phase(const std::string &action)
|
||||
: ActionTypeConfigure(action),
|
||||
m_phase(0),
|
||||
m_secRulesPhase(0) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setPhase(m_phase);
|
||||
}
|
||||
|
||||
|
||||
int m_phase;
|
||||
int m_secRulesPhase;
|
||||
|
||||
@@ -29,12 +29,7 @@ namespace actions {
|
||||
|
||||
|
||||
bool Rev::init(std::string *error) {
|
||||
m_rev = m_parser_payload;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Rev::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
m_revision = m_parser_payload;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_REV_H_
|
||||
#define SRC_ACTIONS_REV_H_
|
||||
@@ -27,16 +28,19 @@ class Transaction;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Rev : public Action {
|
||||
class Rev : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit Rev(const std::string &action) : Action(action, ConfigurationKind) { }
|
||||
explicit Rev(const std::string &action)
|
||||
: ActionTypeConfigure(action),
|
||||
m_revision("")
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
std::string getRevision() const { return m_rev; }
|
||||
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setRevision(m_revision);
|
||||
}
|
||||
private:
|
||||
std::string m_rev;
|
||||
std::string m_revision;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -50,11 +50,5 @@ bool RuleId::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool RuleId::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
rule->setId(m_ruleId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_RULE_ID_H_
|
||||
#define SRC_ACTIONS_RULE_ID_H_
|
||||
@@ -30,15 +31,17 @@ class RuleWithOperator;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class RuleId : public Action {
|
||||
class RuleId : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit RuleId(const std::string &action)
|
||||
: Action(action, ConfigurationKind),
|
||||
: ActionTypeConfigure(action),
|
||||
m_ruleId(0) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setId(m_ruleId);
|
||||
}
|
||||
private:
|
||||
double m_ruleId;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool SetENV::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool SetENV::execute(Transaction *t) {
|
||||
std::string colNameExpanded(getEvaluatedRunTimeString(t));
|
||||
|
||||
ms_dbg_a(t, 8, "Setting envoriment variable: "
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetENV : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new SetENV(*this);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool SetRSC::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool SetRSC::execute(Transaction *t) {
|
||||
std::string colNameExpanded(getEvaluatedRunTimeString(t));
|
||||
ms_dbg_a(t, 8, "RESOURCE initiated with value: \'"
|
||||
+ colNameExpanded + "\'.");
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetRSC : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new SetRSC(*this);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool SetSID::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool SetSID::execute(Transaction *t) {
|
||||
std::string colNameExpanded(getEvaluatedRunTimeString(t));
|
||||
ms_dbg_a(t, 8, "Session ID initiated with value: \'"
|
||||
+ colNameExpanded + "\'.");
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetSID : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new SetSID(*this);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool SetUID::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool SetUID::execute(Transaction *t) {
|
||||
std::string colNameExpanded(getEvaluatedRunTimeString(t));
|
||||
ms_dbg_a(t, 8, "User collection initiated with value: \'"
|
||||
+ colNameExpanded + "\'.");
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetUID : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new SetUID(*this);
|
||||
|
||||
@@ -42,7 +42,7 @@ bool SetVar::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool SetVar::execute(RuleWithActions *rule, Transaction *t) {
|
||||
bool SetVar::execute(Transaction *t) {
|
||||
std::string targetValue;
|
||||
std::string resolvedPre;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class SetVar : public ActionWithRunTimeString {
|
||||
|
||||
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
void populate(RuleWithActions *rule) override {
|
||||
|
||||
@@ -71,7 +71,7 @@ bool Severity::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Severity::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Severity::execute(Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Severity : public Action {
|
||||
: Action(action),
|
||||
m_severity(0) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
int m_severity;
|
||||
|
||||
@@ -38,7 +38,7 @@ bool Skip::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Skip::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Skip::execute(Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 5, "Skipping the next " + \
|
||||
std::to_string(m_skip_next) + " rules.");
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Skip : public Action {
|
||||
m_skip_next(0) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
int m_skip_next;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool SkipAfter::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool SkipAfter::execute(Transaction *transaction) {
|
||||
ms_dbg_a(transaction, 5, "Setting skipAfter for: " + *m_skipName);
|
||||
transaction->addMarker(m_skipName);
|
||||
return true;
|
||||
|
||||
@@ -34,7 +34,7 @@ class SkipAfter : public Action {
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
m_skipName(std::make_shared<std::string>(m_parser_payload)) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
private:
|
||||
std::shared_ptr<std::string> m_skipName;
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Tag::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
bool Tag::execute(Transaction *transaction) {
|
||||
std::string tag = getTagName(transaction);
|
||||
ms_dbg_a(transaction, 9, "Rule tag: " + tag);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class Tag : public ActionWithRunTimeString {
|
||||
: ActionWithRunTimeString(action)
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool execute(Transaction *transaction) override;
|
||||
|
||||
inline std::string getTagName(Transaction *transaction) const {
|
||||
return getEvaluatedRunTimeString(transaction);
|
||||
|
||||
@@ -28,10 +28,5 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Ver::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_VER_H_
|
||||
#define SRC_ACTIONS_VER_H_
|
||||
@@ -27,14 +28,19 @@ class Transaction;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Ver : public Action {
|
||||
class Ver : public ActionTypeConfigure {
|
||||
public:
|
||||
explicit Ver(const std::string &action) : Action(action, ConfigurationKind) { }
|
||||
explicit Ver(const std::string &action)
|
||||
: ActionTypeConfigure(action),
|
||||
m_version("")
|
||||
{ };
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
virtual void configure(RuleWithActions *rule) override {
|
||||
rule->setVersion(m_version);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_ver;
|
||||
std::string m_version;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class XmlNS : public Action {
|
||||
public:
|
||||
explicit XmlNS(const std::string &action) : Action(action) { }
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override {
|
||||
bool execute(Transaction *transaction) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,11 @@
|
||||
#include "src/actions/xmlns.h"
|
||||
#include "src/utils/string.h"
|
||||
#include "src/actions/action_with_run_time_string.h"
|
||||
#include "src/actions/phase.h"
|
||||
#include "src/actions/chain.h"
|
||||
#include "src/actions/rule_id.h"
|
||||
#include "src/actions/ver.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
@@ -113,16 +118,9 @@ void RuleWithActions::addDefaultAction(std::shared_ptr<actions::Action> a) {
|
||||
arts->populate(this);
|
||||
}
|
||||
|
||||
if (a->m_actionKind == Action::ConfigurationKind) {
|
||||
if (dynamic_cast<actions::Accuracy *>(a.get())) {
|
||||
actions::Accuracy *accuracy = dynamic_cast<actions::Accuracy *>(a.get());
|
||||
m_defaultAccuracy = accuracy->getAccuracy();
|
||||
} else if (dynamic_cast<actions::Rev *>(a.get())) {
|
||||
actions::Rev *rev = dynamic_cast<actions::Rev *>(a.get());
|
||||
m_defaultRevision = rev->getRevision();
|
||||
} else {
|
||||
a->execute(this, NULL);
|
||||
}
|
||||
if (dynamic_cast<ActionTypeConfigure *>(a.get())) {
|
||||
ActionTypeConfigure *conf = dynamic_cast<ActionTypeConfigure *>(a.get());
|
||||
conf->configure(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,9 +132,6 @@ void RuleWithActions::addDefaultAction(std::shared_ptr<actions::Action> a) {
|
||||
} else if (dynamic_cast<actions::Severity *>(a.get())) {
|
||||
actions::Severity *severity = dynamic_cast<actions::Severity *>(a.get());
|
||||
setDefaultActionSeverity(severity->m_severity);
|
||||
} else if (dynamic_cast<actions::Maturity *>(a.get())) {
|
||||
actions::Maturity *maturity = dynamic_cast<actions::Maturity *>(a.get());
|
||||
setDefaultActionMaturity(maturity->getMaturity());
|
||||
} else if (dynamic_cast<actions::LogData *>(a.get())) {
|
||||
m_defaultActionLogData = std::static_pointer_cast<actions::LogData>(a);
|
||||
} else if (dynamic_cast<actions::Msg *>(a.get())) {
|
||||
@@ -175,16 +170,9 @@ void RuleWithActions::addAction(actions::Action *a) {
|
||||
arts->populate(this);
|
||||
}
|
||||
|
||||
if (a->m_actionKind == Action::ConfigurationKind) {
|
||||
if (dynamic_cast<actions::Accuracy *>(a)) {
|
||||
actions::Accuracy *accuracy = dynamic_cast<actions::Accuracy *>(a);
|
||||
m_accuracy = accuracy->getAccuracy();
|
||||
} else if (dynamic_cast<actions::Rev *>(a)) {
|
||||
actions::Rev *rev = dynamic_cast<actions::Rev *>(a);
|
||||
m_revision = rev->getRevision();
|
||||
} else {
|
||||
a->execute(this, NULL);
|
||||
}
|
||||
if (dynamic_cast<ActionTypeConfigure *>(a)) {
|
||||
ActionTypeConfigure *conf = dynamic_cast<ActionTypeConfigure *>(a);
|
||||
conf->configure(this);
|
||||
delete a;
|
||||
return;
|
||||
}
|
||||
@@ -207,10 +195,6 @@ void RuleWithActions::addAction(actions::Action *a) {
|
||||
} else if (dynamic_cast<actions::SetVar *>(a)) {
|
||||
actions::SetVar *var = dynamic_cast<actions::SetVar *>(a);
|
||||
m_actionsSetVar.push_back(std::unique_ptr<actions::SetVar>(var));
|
||||
} else if (dynamic_cast<actions::Maturity *>(a)) {
|
||||
actions::Maturity *maturity = dynamic_cast<actions::Maturity *>(a);
|
||||
m_maturity = maturity->getMaturity();
|
||||
delete a;
|
||||
} else if (dynamic_cast<actions::Log *>(a)) {
|
||||
m_containsLogAction = true;
|
||||
delete a;
|
||||
@@ -257,7 +241,7 @@ void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *
|
||||
ms_dbg_a(trans, 4, "Running [independent] (non-disruptive) " \
|
||||
"action: " + *a->m_name.get());
|
||||
|
||||
a->execute(this, trans);
|
||||
a->execute(trans);
|
||||
}
|
||||
|
||||
for (auto &b :
|
||||
@@ -271,20 +255,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);
|
||||
a->execute(trans);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logData) {
|
||||
m_logData->execute(this, trans);
|
||||
m_logData->execute(trans);
|
||||
} else if (m_defaultActionLogData) {
|
||||
m_defaultActionLogData->execute(this, trans);
|
||||
m_defaultActionLogData->execute(trans);
|
||||
}
|
||||
|
||||
if (m_msg) {
|
||||
m_msg->execute(this, trans);
|
||||
m_msg->execute(trans);
|
||||
} else if (m_defaultActionMsg) {
|
||||
m_defaultActionMsg->execute(this, trans);
|
||||
m_defaultActionMsg->execute(trans);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +291,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);
|
||||
a->execute(trans);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,8 +305,13 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans) {
|
||||
continue;
|
||||
}
|
||||
actions::Action *a = dynamic_cast<actions::Action*>(b.second.get());
|
||||
if (a->isDisruptive()) {
|
||||
trans->messageGetLast()->setRule(this);
|
||||
}
|
||||
executeAction(trans, a, false);
|
||||
disruptiveAlreadyExecuted = true;
|
||||
if (a->isDisruptive()) {
|
||||
disruptiveAlreadyExecuted = true;
|
||||
}
|
||||
}
|
||||
for (auto &a : getMatchActionsPtr()) {
|
||||
if (!a->isDisruptive()
|
||||
@@ -348,7 +337,7 @@ void RuleWithActions::executeAction(Transaction *trans,
|
||||
if (a->isDisruptive() == false && *a->m_name.get() != "block") {
|
||||
ms_dbg_a(trans, 9, "Running " \
|
||||
"action: " + *a->m_name.get());
|
||||
a->execute(this, trans);
|
||||
a->execute(trans);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,7 +350,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);
|
||||
a->execute(trans);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/variable_value.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "src/actions/action_type_configure.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -53,6 +55,7 @@ using Transformation = actions::transformations::Transformation;
|
||||
using Transformations = std::vector<std::shared_ptr<Transformation> >;
|
||||
using TransformationsPtr = std::vector<Transformation *>;
|
||||
using Action = actions::Action;
|
||||
using ActionTypeConfigure = actions::ActionTypeConfigure;
|
||||
using Actions = std::vector<actions::Action *>;
|
||||
using Tags = std::vector<std::shared_ptr<actions::Tag> >;
|
||||
using TagsPtr = std::vector<actions::Tag *>;
|
||||
|
||||
Reference in New Issue
Block a user