mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Simplified initialization of Transformation's action_kind
- Some of the Transformation classes would initialize their Action's action_kind using the default (using Transformation constructor without an action_kind parameter). - Others, however, would use that constructor and initialize action_kind manually in their constructor, but setting the default value (RunTimeBeforeMatchAttemptKind = 1), which was redundant. - Removed unused Transformation constructor to specify action_kind. - Converted Action::Kind into an 'enum class' to require using the enum constants (instead of integer values, which are difficult to track in the codebase and change)
This commit is contained in:
@@ -32,15 +32,47 @@ namespace actions {
|
|||||||
|
|
||||||
class Action {
|
class Action {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Define the action kind regarding to the execution time.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum class Kind {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Action that are executed while loading the configuration. For instance
|
||||||
|
* the rule ID or the rule phase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ConfigurationKind,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Those are actions that demands to be executed before call the operator.
|
||||||
|
* For instance the tranformations.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
RunTimeBeforeMatchAttemptKind,
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Actions that are executed after the execution of the operator, only if
|
||||||
|
* the operator returned Match (or True). For instance the disruptive
|
||||||
|
* actions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
RunTimeOnlyIfMatchKind,
|
||||||
|
};
|
||||||
|
|
||||||
explicit Action(const std::string& _action)
|
explicit Action(const std::string& _action)
|
||||||
: m_isNone(false),
|
: m_isNone(false),
|
||||||
temporaryAction(false),
|
temporaryAction(false),
|
||||||
action_kind(2),
|
action_kind(Kind::RunTimeOnlyIfMatchKind),
|
||||||
m_name(nullptr),
|
m_name(nullptr),
|
||||||
m_parser_payload("") {
|
m_parser_payload("") {
|
||||||
set_name_and_payload(_action);
|
set_name_and_payload(_action);
|
||||||
}
|
}
|
||||||
explicit Action(const std::string& _action, int kind)
|
explicit Action(const std::string& _action, Kind kind)
|
||||||
: m_isNone(false),
|
: m_isNone(false),
|
||||||
temporaryAction(false),
|
temporaryAction(false),
|
||||||
action_kind(kind),
|
action_kind(kind),
|
||||||
@@ -100,41 +132,9 @@ class Action {
|
|||||||
|
|
||||||
bool m_isNone;
|
bool m_isNone;
|
||||||
bool temporaryAction;
|
bool temporaryAction;
|
||||||
int action_kind;
|
Kind action_kind;
|
||||||
std::shared_ptr<std::string> m_name;
|
std::shared_ptr<std::string> m_name;
|
||||||
std::string m_parser_payload;
|
std::string m_parser_payload;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Define the action kind regarding to the execution time.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
enum Kind {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Action that are executed while loading the configuration. For instance
|
|
||||||
* the rule ID or the rule phase.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
ConfigurationKind,
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Those are actions that demands to be executed before call the operator.
|
|
||||||
* For instance the tranformations.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
RunTimeBeforeMatchAttemptKind,
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Actions that are executed after the execution of the operator, only if
|
|
||||||
* the operator returned Match (or True). For instance the disruptive
|
|
||||||
* actions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
RunTimeOnlyIfMatchKind,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ namespace actions {
|
|||||||
class Accuracy : public Action {
|
class Accuracy : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Accuracy(const std::string &action)
|
explicit Accuracy(const std::string &action)
|
||||||
: Action(action, ConfigurationKind),
|
: Action(action, Kind::ConfigurationKind),
|
||||||
m_accuracy(0) { }
|
m_accuracy(0) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -33,7 +33,7 @@ namespace actions {
|
|||||||
class AuditLog : public Action {
|
class AuditLog : public Action {
|
||||||
public:
|
public:
|
||||||
explicit AuditLog(const std::string &action)
|
explicit AuditLog(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
std::shared_ptr<RuleMessage> rm) override;
|
std::shared_ptr<RuleMessage> rm) override;
|
||||||
|
@@ -29,7 +29,7 @@ namespace actions {
|
|||||||
class Capture : public Action {
|
class Capture : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Capture(const std::string &action)
|
explicit Capture(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
@@ -33,7 +33,7 @@ namespace actions {
|
|||||||
class Chain : public Action {
|
class Chain : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Chain(const std::string &action)
|
explicit Chain(const std::string &action)
|
||||||
: Action(action, ConfigurationKind) { }
|
: Action(action, Kind::ConfigurationKind) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
@@ -34,7 +34,7 @@ namespace ctl {
|
|||||||
class AuditEngine : public Action {
|
class AuditEngine : public Action {
|
||||||
public:
|
public:
|
||||||
explicit AuditEngine(const std::string &action)
|
explicit AuditEngine(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_auditEngine(audit_log::AuditLog::AuditLogStatus::NotSetLogStatus) { }
|
m_auditEngine(audit_log::AuditLog::AuditLogStatus::NotSetLogStatus) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -29,7 +29,7 @@ namespace ctl {
|
|||||||
class AuditLogParts : public Action {
|
class AuditLogParts : public Action {
|
||||||
public:
|
public:
|
||||||
explicit AuditLogParts(const std::string &action)
|
explicit AuditLogParts(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
mPartsAction(0),
|
mPartsAction(0),
|
||||||
mParts("") { }
|
mParts("") { }
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ namespace ctl {
|
|||||||
class RequestBodyAccess : public Action {
|
class RequestBodyAccess : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RequestBodyAccess(const std::string &action)
|
explicit RequestBodyAccess(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_request_body_access(false) { }
|
m_request_body_access(false) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -29,7 +29,7 @@ namespace ctl {
|
|||||||
class RequestBodyProcessorJSON : public Action {
|
class RequestBodyProcessorJSON : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RequestBodyProcessorJSON(const std::string &action)
|
explicit RequestBodyProcessorJSON(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
@@ -29,7 +29,7 @@ namespace ctl {
|
|||||||
class RequestBodyProcessorURLENCODED : public Action {
|
class RequestBodyProcessorURLENCODED : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RequestBodyProcessorURLENCODED(const std::string &action)
|
explicit RequestBodyProcessorURLENCODED(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
@@ -29,7 +29,7 @@ namespace ctl {
|
|||||||
class RequestBodyProcessorXML : public Action {
|
class RequestBodyProcessorXML : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RequestBodyProcessorXML(const std::string &action)
|
explicit RequestBodyProcessorXML(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
@@ -31,7 +31,7 @@ namespace ctl {
|
|||||||
class RuleEngine : public Action {
|
class RuleEngine : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleEngine(const std::string &action)
|
explicit RuleEngine(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_ruleEngine(RulesSetProperties::PropertyNotSetRuleEngine) { }
|
m_ruleEngine(RulesSetProperties::PropertyNotSetRuleEngine) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -30,7 +30,7 @@ namespace ctl {
|
|||||||
class RuleRemoveById : public Action {
|
class RuleRemoveById : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleRemoveById(const std::string &action)
|
explicit RuleRemoveById(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -30,7 +30,7 @@ namespace ctl {
|
|||||||
class RuleRemoveByTag : public Action {
|
class RuleRemoveByTag : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleRemoveByTag(const std::string &action)
|
explicit RuleRemoveByTag(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_tag("") { }
|
m_tag("") { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -30,7 +30,7 @@ namespace ctl {
|
|||||||
class RuleRemoveTargetById : public Action {
|
class RuleRemoveTargetById : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleRemoveTargetById(const std::string &action)
|
explicit RuleRemoveTargetById(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_id(0),
|
m_id(0),
|
||||||
m_target("") { }
|
m_target("") { }
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ namespace ctl {
|
|||||||
class RuleRemoveTargetByTag : public Action {
|
class RuleRemoveTargetByTag : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleRemoveTargetByTag(const std::string &action)
|
explicit RuleRemoveTargetByTag(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -33,8 +33,8 @@ namespace data {
|
|||||||
|
|
||||||
class Status : public Action {
|
class Status : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Status(const std::string &action) : Action(action, 2),
|
explicit Status(const std::string &action)
|
||||||
m_status(0) { }
|
: Action(action), m_status(0) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
|
@@ -54,7 +54,7 @@ enum AllowType : int {
|
|||||||
class Allow : public Action {
|
class Allow : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Allow(const std::string &action)
|
explicit Allow(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_allowType(NoneAllowType) { }
|
m_allowType(NoneAllowType) { }
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,12 +37,12 @@ namespace disruptive {
|
|||||||
class Redirect : public Action {
|
class Redirect : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Redirect(const std::string &action)
|
explicit Redirect(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_status(0),
|
m_status(0),
|
||||||
m_string(nullptr) { }
|
m_string(nullptr) { }
|
||||||
|
|
||||||
explicit Redirect(std::unique_ptr<RunTimeString> z)
|
explicit Redirect(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("redirert", RunTimeOnlyIfMatchKind),
|
: Action("redirert"),
|
||||||
m_status(0),
|
m_status(0),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ class ExpireVar : public Action {
|
|||||||
explicit ExpireVar(const std::string &action) : Action(action) { }
|
explicit ExpireVar(const std::string &action) : Action(action) { }
|
||||||
|
|
||||||
explicit ExpireVar(std::unique_ptr<RunTimeString> z)
|
explicit ExpireVar(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("expirevar", RunTimeOnlyIfMatchKind),
|
: Action("expirevar"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -35,7 +35,7 @@ class InitCol : public Action {
|
|||||||
explicit InitCol(const std::string &action) : Action(action) { }
|
explicit InitCol(const std::string &action) : Action(action) { }
|
||||||
|
|
||||||
InitCol(const std::string &action, std::unique_ptr<RunTimeString> z)
|
InitCol(const std::string &action, std::unique_ptr<RunTimeString> z)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -31,7 +31,7 @@ namespace actions {
|
|||||||
class Log : public Action {
|
class Log : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Log(const std::string &action)
|
explicit Log(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
std::shared_ptr<RuleMessage> rm) override;
|
std::shared_ptr<RuleMessage> rm) override;
|
||||||
|
@@ -33,10 +33,10 @@ namespace actions {
|
|||||||
class LogData : public Action {
|
class LogData : public Action {
|
||||||
public:
|
public:
|
||||||
explicit LogData(const std::string &action)
|
explicit LogData(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
explicit LogData(std::unique_ptr<RunTimeString> z)
|
explicit LogData(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("logdata", RunTimeOnlyIfMatchKind),
|
: Action("logdata"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
|
@@ -30,7 +30,7 @@ namespace actions {
|
|||||||
class Maturity : public Action {
|
class Maturity : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Maturity(const std::string &action)
|
explicit Maturity(const std::string &action)
|
||||||
: Action(action, ConfigurationKind),
|
: Action(action, Kind::ConfigurationKind),
|
||||||
m_maturity(0) { }
|
m_maturity(0) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -34,10 +34,10 @@ namespace actions {
|
|||||||
class Msg : public Action {
|
class Msg : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Msg(const std::string &action)
|
explicit Msg(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
explicit Msg(std::unique_ptr<RunTimeString> z)
|
explicit Msg(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("msg", RunTimeOnlyIfMatchKind),
|
: Action("msg"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
|
@@ -33,7 +33,7 @@ namespace actions {
|
|||||||
class MultiMatch : public Action {
|
class MultiMatch : public Action {
|
||||||
public:
|
public:
|
||||||
explicit MultiMatch(const std::string &action)
|
explicit MultiMatch(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
@@ -33,7 +33,7 @@ namespace actions {
|
|||||||
class NoAuditLog : public Action {
|
class NoAuditLog : public Action {
|
||||||
public:
|
public:
|
||||||
explicit NoAuditLog(const std::string &action)
|
explicit NoAuditLog(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
std::shared_ptr<RuleMessage> rm) override;
|
std::shared_ptr<RuleMessage> rm) override;
|
||||||
|
@@ -31,7 +31,7 @@ namespace actions {
|
|||||||
class NoLog : public Action {
|
class NoLog : public Action {
|
||||||
public:
|
public:
|
||||||
explicit NoLog(const std::string &action)
|
explicit NoLog(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
: Action(action) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
bool evaluate(RuleWithActions *rule, Transaction *transaction,
|
||||||
std::shared_ptr<RuleMessage> rm) override;
|
std::shared_ptr<RuleMessage> rm) override;
|
||||||
|
@@ -32,7 +32,7 @@ namespace actions {
|
|||||||
|
|
||||||
class Phase : public Action {
|
class Phase : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Phase(const std::string &action) : Action(action, ConfigurationKind),
|
explicit Phase(const std::string &action) : Action(action, Kind::ConfigurationKind),
|
||||||
m_phase(0),
|
m_phase(0),
|
||||||
m_secRulesPhase(0) { }
|
m_secRulesPhase(0) { }
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ namespace actions {
|
|||||||
|
|
||||||
class Rev : public Action {
|
class Rev : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Rev(const std::string &action) : Action(action, ConfigurationKind) { }
|
explicit Rev(const std::string &action) : Action(action, Kind::ConfigurationKind) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -33,7 +33,7 @@ namespace actions {
|
|||||||
class RuleId : public Action {
|
class RuleId : public Action {
|
||||||
public:
|
public:
|
||||||
explicit RuleId(const std::string &action)
|
explicit RuleId(const std::string &action)
|
||||||
: Action(action, ConfigurationKind),
|
: Action(action, Kind::ConfigurationKind),
|
||||||
m_ruleId(0) { }
|
m_ruleId(0) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -36,7 +36,7 @@ class SetENV : public Action {
|
|||||||
: Action(_action) { }
|
: Action(_action) { }
|
||||||
|
|
||||||
explicit SetENV(std::unique_ptr<RunTimeString> z)
|
explicit SetENV(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("setenv", RunTimeOnlyIfMatchKind),
|
: Action("setenv"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -36,7 +36,7 @@ class SetRSC : public Action {
|
|||||||
: Action(_action) { }
|
: Action(_action) { }
|
||||||
|
|
||||||
explicit SetRSC(std::unique_ptr<RunTimeString> z)
|
explicit SetRSC(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("setsrc", RunTimeOnlyIfMatchKind),
|
: Action("setsrc"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -36,7 +36,7 @@ class SetSID : public Action {
|
|||||||
: Action(_action) { }
|
: Action(_action) { }
|
||||||
|
|
||||||
explicit SetSID(std::unique_ptr<RunTimeString> z)
|
explicit SetSID(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("setsid", RunTimeOnlyIfMatchKind),
|
: Action("setsid"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -36,7 +36,7 @@ class SetUID : public Action {
|
|||||||
: Action(_action) { }
|
: Action(_action) { }
|
||||||
|
|
||||||
explicit SetUID(std::unique_ptr<RunTimeString> z)
|
explicit SetUID(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("setuid", RunTimeOnlyIfMatchKind),
|
: Action("setuid"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -30,7 +30,7 @@ namespace actions {
|
|||||||
class Skip : public Action {
|
class Skip : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Skip(const std::string &action)
|
explicit Skip(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_skip_next(0) { }
|
m_skip_next(0) { }
|
||||||
|
|
||||||
bool init(std::string *error) override;
|
bool init(std::string *error) override;
|
||||||
|
@@ -31,7 +31,7 @@ namespace actions {
|
|||||||
class SkipAfter : public Action {
|
class SkipAfter : public Action {
|
||||||
public:
|
public:
|
||||||
explicit SkipAfter(const std::string &action)
|
explicit SkipAfter(const std::string &action)
|
||||||
: Action(action, RunTimeOnlyIfMatchKind),
|
: Action(action),
|
||||||
m_skipName(std::make_shared<std::string>(m_parser_payload)) { }
|
m_skipName(std::make_shared<std::string>(m_parser_payload)) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
@@ -33,7 +33,7 @@ namespace actions {
|
|||||||
class Tag : public Action {
|
class Tag : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Tag(std::unique_ptr<RunTimeString> z)
|
explicit Tag(std::unique_ptr<RunTimeString> z)
|
||||||
: Action("tag", RunTimeOnlyIfMatchKind),
|
: Action("tag"),
|
||||||
m_string(std::move(z)) { }
|
m_string(std::move(z)) { }
|
||||||
|
|
||||||
std::string getName(Transaction *transaction);
|
std::string getName(Transaction *transaction);
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Base64Decode : public Transformation {
|
class Base64Decode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Base64Decode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Base64DecodeExt : public Transformation {
|
class Base64DecodeExt : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Base64DecodeExt(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Base64Encode : public Transformation {
|
class Base64Encode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Base64Encode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class CmdLine : public Transformation {
|
class CmdLine : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit CmdLine(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -19,11 +19,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
CompressWhitespace::CompressWhitespace(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CompressWhitespace::transform(std::string &value, const Transaction *trans) const {
|
bool CompressWhitespace::transform(std::string &value, const Transaction *trans) const {
|
||||||
bool inWhiteSpace = false;
|
bool inWhiteSpace = false;
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class CompressWhitespace : public Transformation {
|
class CompressWhitespace : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit CompressWhitespace(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class CssDecode : public Transformation {
|
class CssDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit CssDecode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -20,12 +20,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
EscapeSeqDecode::EscapeSeqDecode(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline int ansi_c_sequences_decode_inplace(std::string &value) {
|
static inline int ansi_c_sequences_decode_inplace(std::string &value) {
|
||||||
auto d = reinterpret_cast<unsigned char *>(value.data());
|
auto d = reinterpret_cast<unsigned char *>(value.data());
|
||||||
const unsigned char* input = d;
|
const unsigned char* input = d;
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class EscapeSeqDecode : public Transformation {
|
class EscapeSeqDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit EscapeSeqDecode(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class HexDecode : public Transformation {
|
class HexDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit HexDecode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -20,10 +20,6 @@
|
|||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
HexEncode::HexEncode(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HexEncode::transform(std::string &value, const Transaction *trans) const {
|
bool HexEncode::transform(std::string &value, const Transaction *trans) const {
|
||||||
if (value.empty()) return false;
|
if (value.empty()) return false;
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class HexEncode : public Transformation {
|
class HexEncode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit HexEncode(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class HtmlEntityDecode : public Transformation {
|
class HtmlEntityDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit HtmlEntityDecode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class JsDecode : public Transformation {
|
class JsDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit JsDecode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -19,11 +19,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
Length::Length(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Length::transform(std::string &value, const Transaction *trans) const {
|
bool Length::transform(std::string &value, const Transaction *trans) const {
|
||||||
value = std::to_string(value.size());
|
value = std::to_string(value.size());
|
||||||
return true;
|
return true;
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Length : public Transformation {
|
class Length : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Length(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,10 +22,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
LowerCase::LowerCase(const std::string &a)
|
|
||||||
: Transformation(a) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LowerCase::transform(std::string &value, const Transaction *trans) const {
|
bool LowerCase::transform(std::string &value, const Transaction *trans) const {
|
||||||
return convert(value, [](auto c) {
|
return convert(value, [](auto c) {
|
||||||
return std::tolower(c); });
|
return std::tolower(c); });
|
||||||
|
@@ -24,7 +24,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class LowerCase : public Transformation {
|
class LowerCase : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit LowerCase(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
|
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Md5 : public Transformation {
|
class Md5 : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Md5(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -19,11 +19,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
NormalisePath::NormalisePath(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NormalisePath::transform(std::string &value, const Transaction *trans) const {
|
bool NormalisePath::transform(std::string &value, const Transaction *trans) const {
|
||||||
return normalize_path_inplace(value, false);
|
return normalize_path_inplace(value, false);
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class NormalisePath : public Transformation {
|
class NormalisePath : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit NormalisePath(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
|
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class NormalisePathWin : public Transformation {
|
class NormalisePathWin : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit NormalisePathWin(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class ParityEven7bit : public Transformation {
|
class ParityEven7bit : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit ParityEven7bit(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
|
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class ParityOdd7bit : public Transformation {
|
class ParityOdd7bit : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit ParityOdd7bit(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class ParityZero7bit : public Transformation {
|
class ParityZero7bit : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit ParityZero7bit(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class RemoveComments : public Transformation {
|
class RemoveComments : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit RemoveComments(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -18,10 +18,6 @@
|
|||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
RemoveCommentsChar::RemoveCommentsChar(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RemoveCommentsChar::transform(std::string &value, const Transaction *trans) const {
|
bool RemoveCommentsChar::transform(std::string &value, const Transaction *trans) const {
|
||||||
char *d = value.data();
|
char *d = value.data();
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class RemoveCommentsChar : public Transformation {
|
class RemoveCommentsChar : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit RemoveCommentsChar(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -24,8 +24,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class RemoveNulls : public Transformation {
|
class RemoveNulls : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit RemoveNulls(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
|
|
||||||
|
@@ -20,11 +20,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
RemoveWhitespace::RemoveWhitespace(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RemoveWhitespace::transform(std::string &value, const Transaction *trans) const {
|
bool RemoveWhitespace::transform(std::string &value, const Transaction *trans) const {
|
||||||
const char nonBreakingSpaces = 0xa0;
|
const char nonBreakingSpaces = 0xa0;
|
||||||
const char nonBreakingSpaces2 = 0xc2;
|
const char nonBreakingSpaces2 = 0xc2;
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class RemoveWhitespace : public Transformation {
|
class RemoveWhitespace : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit RemoveWhitespace(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -59,12 +59,6 @@ static inline bool inplace(std::string &value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReplaceComments::ReplaceComments(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ReplaceComments::transform(std::string &value, const Transaction *trans) const {
|
bool ReplaceComments::transform(std::string &value, const Transaction *trans) const {
|
||||||
return inplace(value);
|
return inplace(value);
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class ReplaceComments : public Transformation {
|
class ReplaceComments : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit ReplaceComments(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -18,10 +18,6 @@
|
|||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
ReplaceNulls::ReplaceNulls(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ReplaceNulls::transform(std::string &value, const Transaction *trans) const {
|
bool ReplaceNulls::transform(std::string &value, const Transaction *trans) const {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class ReplaceNulls : public Transformation {
|
class ReplaceNulls : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit ReplaceNulls(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -20,14 +20,11 @@
|
|||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
Sha1::Sha1(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Sha1::transform(std::string &value, const Transaction *trans) const {
|
bool Sha1::transform(std::string &value, const Transaction *trans) const {
|
||||||
value = Utils::Sha1::digest(value);
|
value = Utils::Sha1::digest(value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace modsecurity::actions::transformations
|
} // namespace modsecurity::actions::transformations
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Sha1 : public Transformation {
|
class Sha1 : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Sha1(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class SqlHexDecode : public Transformation {
|
class SqlHexDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit SqlHexDecode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -23,10 +23,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
class Transformation : public Action {
|
class Transformation : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Transformation(const std::string& _action)
|
explicit Transformation(const std::string& _action)
|
||||||
: Action(_action, RunTimeBeforeMatchAttemptKind) { }
|
: Action(_action, Kind::RunTimeBeforeMatchAttemptKind) { }
|
||||||
|
|
||||||
explicit Transformation(const std::string& _action, int kind)
|
|
||||||
: Action(_action, kind) { }
|
|
||||||
|
|
||||||
static Transformation* instantiate(std::string a);
|
static Transformation* instantiate(std::string a);
|
||||||
|
|
||||||
|
@@ -55,12 +55,6 @@ bool Trim::trim(std::string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Trim::Trim(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Trim::transform(std::string &value, const Transaction *trans) const {
|
bool Trim::transform(std::string &value, const Transaction *trans) const {
|
||||||
return trim(value);
|
return trim(value);
|
||||||
}
|
}
|
||||||
|
@@ -22,12 +22,10 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Trim : public Transformation {
|
class Trim : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Trim(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
static bool ltrim(std::string &s);
|
static bool ltrim(std::string &s);
|
||||||
static bool rtrim(std::string &s);
|
static bool rtrim(std::string &s);
|
||||||
static bool trim(std::string &s);
|
static bool trim(std::string &s);
|
||||||
|
@@ -14,19 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "trim_left.h"
|
#include "trim_left.h"
|
||||||
|
#include "trim.h"
|
||||||
|
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TrimLeft::TrimLeft(const std::string &action)
|
|
||||||
: Trim(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrimLeft::transform(std::string &value, const Transaction *trans) const {
|
bool TrimLeft::transform(std::string &value, const Transaction *trans) const {
|
||||||
return ltrim(value);
|
return Trim::ltrim(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,13 +17,12 @@
|
|||||||
#define SRC_ACTIONS_TRANSFORMATIONS_TRIM_LEFT_H_
|
#define SRC_ACTIONS_TRANSFORMATIONS_TRIM_LEFT_H_
|
||||||
|
|
||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
#include "trim.h"
|
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
class TrimLeft : public Trim {
|
class TrimLeft : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit TrimLeft(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -14,18 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "trim_right.h"
|
#include "trim_right.h"
|
||||||
|
#include "trim.h"
|
||||||
|
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
TrimRight::TrimRight(const std::string &action)
|
|
||||||
: Trim(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TrimRight::transform(std::string &value, const Transaction *trans) const {
|
bool TrimRight::transform(std::string &value, const Transaction *trans) const {
|
||||||
return rtrim(value);
|
return Trim::rtrim(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,13 +17,12 @@
|
|||||||
#define SRC_ACTIONS_TRANSFORMATIONS_TRIM_RIGHT_H_
|
#define SRC_ACTIONS_TRANSFORMATIONS_TRIM_RIGHT_H_
|
||||||
|
|
||||||
#include "transformation.h"
|
#include "transformation.h"
|
||||||
#include "trim.h"
|
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
class TrimRight : public Trim {
|
class TrimRight : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit TrimRight(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -24,10 +24,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
UpperCase::UpperCase(const std::string &a)
|
|
||||||
: Transformation(a) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UpperCase::transform(std::string &value, const Transaction *trans) const {
|
bool UpperCase::transform(std::string &value, const Transaction *trans) const {
|
||||||
return LowerCase::convert(value, [](auto c)
|
return LowerCase::convert(value, [](auto c)
|
||||||
{ return std::toupper(c); });
|
{ return std::toupper(c); });
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class UpperCase : public Transformation {
|
class UpperCase : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit UpperCase(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -21,11 +21,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
UrlDecode::UrlDecode(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UrlDecode::transform(std::string &value, const Transaction *trans) const {
|
bool UrlDecode::transform(std::string &value, const Transaction *trans) const {
|
||||||
int invalid_count;
|
int invalid_count;
|
||||||
return utils::urldecode_nonstrict_inplace(value, invalid_count);
|
return utils::urldecode_nonstrict_inplace(value, invalid_count);
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class UrlDecode : public Transformation {
|
class UrlDecode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit UrlDecode(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class UrlDecodeUni : public Transformation {
|
class UrlDecodeUni : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit UrlDecodeUni(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -20,12 +20,6 @@
|
|||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
UrlEncode::UrlEncode(const std::string &action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline bool url_enc(std::string &value) {
|
static inline bool url_enc(std::string &value) {
|
||||||
const auto len = value.size() * 3 + 1;
|
const auto len = value.size() * 3 + 1;
|
||||||
std::string ret(len, {});
|
std::string ret(len, {});
|
||||||
|
@@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class UrlEncode : public Transformation {
|
class UrlEncode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit UrlEncode(const std::string &action);
|
using Transformation::Transformation;
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -22,8 +22,7 @@ namespace modsecurity::actions::transformations {
|
|||||||
|
|
||||||
class Utf8ToUnicode : public Transformation {
|
class Utf8ToUnicode : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit Utf8ToUnicode(const std::string &action)
|
using Transformation::Transformation;
|
||||||
: Transformation(action) { }
|
|
||||||
|
|
||||||
bool transform(std::string &value, const Transaction *trans) const override;
|
bool transform(std::string &value, const Transaction *trans) const override;
|
||||||
};
|
};
|
||||||
|
@@ -29,7 +29,7 @@ namespace actions {
|
|||||||
|
|
||||||
class Ver : public Action {
|
class Ver : public Action {
|
||||||
public:
|
public:
|
||||||
explicit Ver(const std::string &action) : Action(action, ConfigurationKind) { }
|
explicit Ver(const std::string &action) : Action(action, Kind::ConfigurationKind) { }
|
||||||
|
|
||||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||||
|
|
||||||
|
@@ -2424,8 +2424,8 @@ namespace yy {
|
|||||||
definedPhase = phase->m_phase;
|
definedPhase = phase->m_phase;
|
||||||
secRuleDefinedPhase = phase->m_secRulesPhase;
|
secRuleDefinedPhase = phase->m_secRulesPhase;
|
||||||
delete phase;
|
delete phase;
|
||||||
} else if (a->action_kind == actions::Action::RunTimeOnlyIfMatchKind ||
|
} else if (a->action_kind == actions::Action::Kind::RunTimeOnlyIfMatchKind ||
|
||||||
a->action_kind == actions::Action::RunTimeBeforeMatchAttemptKind) {
|
a->action_kind == actions::Action::Kind::RunTimeBeforeMatchAttemptKind) {
|
||||||
actions::transformations::None *none = dynamic_cast<actions::transformations::None *>(a);
|
actions::transformations::None *none = dynamic_cast<actions::transformations::None *>(a);
|
||||||
if (none != NULL) {
|
if (none != NULL) {
|
||||||
driver.error(yystack_[2].location, "The transformation none is not suitable to be part of the SecDefaultActions");
|
driver.error(yystack_[2].location, "The transformation none is not suitable to be part of the SecDefaultActions");
|
||||||
|
@@ -1199,8 +1199,8 @@ expression:
|
|||||||
definedPhase = phase->m_phase;
|
definedPhase = phase->m_phase;
|
||||||
secRuleDefinedPhase = phase->m_secRulesPhase;
|
secRuleDefinedPhase = phase->m_secRulesPhase;
|
||||||
delete phase;
|
delete phase;
|
||||||
} else if (a->action_kind == actions::Action::RunTimeOnlyIfMatchKind ||
|
} else if (a->action_kind == actions::Action::Kind::RunTimeOnlyIfMatchKind ||
|
||||||
a->action_kind == actions::Action::RunTimeBeforeMatchAttemptKind) {
|
a->action_kind == actions::Action::Kind::RunTimeBeforeMatchAttemptKind) {
|
||||||
actions::transformations::None *none = dynamic_cast<actions::transformations::None *>(a);
|
actions::transformations::None *none = dynamic_cast<actions::transformations::None *>(a);
|
||||||
if (none != NULL) {
|
if (none != NULL) {
|
||||||
driver.error(@0, "The transformation none is not suitable to be part of the SecDefaultActions");
|
driver.error(@0, "The transformation none is not suitable to be part of the SecDefaultActions");
|
||||||
|
@@ -89,11 +89,11 @@ RuleWithActions::RuleWithActions(
|
|||||||
if (actions) {
|
if (actions) {
|
||||||
for (Action *a : *actions) {
|
for (Action *a : *actions) {
|
||||||
switch (a->action_kind) {
|
switch (a->action_kind) {
|
||||||
case Action::ConfigurationKind:
|
case Action::Kind::ConfigurationKind:
|
||||||
a->evaluate(this, NULL);
|
a->evaluate(this, NULL);
|
||||||
delete a;
|
delete a;
|
||||||
break;
|
break;
|
||||||
case Action::RunTimeOnlyIfMatchKind:
|
case Action::Kind::RunTimeOnlyIfMatchKind:
|
||||||
if (dynamic_cast<actions::Capture *>(a)) {
|
if (dynamic_cast<actions::Capture *>(a)) {
|
||||||
m_containsCaptureAction = true;
|
m_containsCaptureAction = true;
|
||||||
delete a;
|
delete a;
|
||||||
@@ -247,7 +247,7 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans,
|
|||||||
bool disruptiveAlreadyExecuted = false;
|
bool disruptiveAlreadyExecuted = false;
|
||||||
|
|
||||||
for (const auto &a : trans->m_rules->m_defaultActions[getPhase()]) { // cppcheck-suppress ctunullpointer
|
for (const auto &a : trans->m_rules->m_defaultActions[getPhase()]) { // cppcheck-suppress ctunullpointer
|
||||||
if (a.get()->action_kind != actions::Action::RunTimeOnlyIfMatchKind) {
|
if (a.get()->action_kind != actions::Action::Kind::RunTimeOnlyIfMatchKind) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!a.get()->isDisruptive()) {
|
if (!a.get()->isDisruptive()) {
|
||||||
@@ -374,7 +374,7 @@ void RuleWithActions::executeTransformations(
|
|||||||
if (none == 0) {
|
if (none == 0) {
|
||||||
for (auto &a : trans->m_rules->m_defaultActions[getPhase()]) {
|
for (auto &a : trans->m_rules->m_defaultActions[getPhase()]) {
|
||||||
if (a->action_kind \
|
if (a->action_kind \
|
||||||
!= actions::Action::RunTimeBeforeMatchAttemptKind) {
|
!= actions::Action::Kind::RunTimeBeforeMatchAttemptKind) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,15 +36,15 @@ bool RulesExceptions::loadUpdateActionById(double id,
|
|||||||
std::string *error) {
|
std::string *error) {
|
||||||
|
|
||||||
for (auto &a : *actions) {
|
for (auto &a : *actions) {
|
||||||
if (a->action_kind == actions::Action::ConfigurationKind) {
|
if (a->action_kind == actions::Action::Kind::ConfigurationKind) {
|
||||||
std::cout << "General failure, action: " << a->m_name;
|
std::cout << "General failure, action: " << a->m_name;
|
||||||
std::cout << " has not expected to be used with UpdateActionByID.";
|
std::cout << " has not expected to be used with UpdateActionByID.";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
} else if (a->action_kind
|
} else if (a->action_kind
|
||||||
== actions::Action::RunTimeBeforeMatchAttemptKind) {
|
== actions::Action::Kind::RunTimeBeforeMatchAttemptKind) {
|
||||||
m_action_pre_update_target_by_id.emplace(std::pair<double,
|
m_action_pre_update_target_by_id.emplace(std::pair<double,
|
||||||
std::unique_ptr<actions::Action>>(id , std::move(a)));
|
std::unique_ptr<actions::Action>>(id , std::move(a)));
|
||||||
} else if (a->action_kind == actions::Action::RunTimeOnlyIfMatchKind) {
|
} else if (a->action_kind == actions::Action::Kind::RunTimeOnlyIfMatchKind) {
|
||||||
m_action_pos_update_target_by_id.emplace(std::pair<double,
|
m_action_pos_update_target_by_id.emplace(std::pair<double,
|
||||||
std::unique_ptr<actions::Action>>(id , std::move(a)));
|
std::unique_ptr<actions::Action>>(id , std::move(a)));
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user