mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Refactoring: moves ctl_ actions into ctl namespace
This commit is contained in:
parent
2bb9d7988f
commit
9733cacd4d
@ -100,13 +100,13 @@ ACTIONS = \
|
||||
actions/block.cc \
|
||||
actions/capture.cc \
|
||||
actions/chain.cc \
|
||||
actions/ctl_audit_log_parts.cc \
|
||||
actions/ctl_request_body_processor_json.cc \
|
||||
actions/ctl_request_body_processor_xml.cc \
|
||||
actions/ctl_rule_remove_target_by_tag.cc \
|
||||
actions/ctl_rule_remove_target_by_id.cc \
|
||||
actions/ctl_rule_remove_by_id.cc \
|
||||
actions/ctl_request_body_access.cc\
|
||||
actions/ctl/audit_log_parts.cc \
|
||||
actions/ctl/request_body_processor_json.cc \
|
||||
actions/ctl/request_body_processor_xml.cc \
|
||||
actions/ctl/rule_remove_target_by_tag.cc \
|
||||
actions/ctl/rule_remove_target_by_id.cc \
|
||||
actions/ctl/rule_remove_by_id.cc \
|
||||
actions/ctl/request_body_access.cc\
|
||||
actions/init_col.cc \
|
||||
actions/deny.cc \
|
||||
actions/log.cc \
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_audit_log_parts.h"
|
||||
#include "actions/ctl/audit_log_parts.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -22,8 +22,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
bool CtlAuditLogParts::init(std::string *error) {
|
||||
|
||||
bool AuditLogParts::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 14, 1);
|
||||
mParts = std::string(m_parser_payload, 15, m_parser_payload.length()-15);
|
||||
if (what == "+") {
|
||||
@ -35,11 +37,13 @@ bool CtlAuditLogParts::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CtlAuditLogParts::evaluate(Rule *rule, Transaction *transaction) {
|
||||
bool AuditLogParts::evaluate(Rule *rule, Transaction *transaction) {
|
||||
transaction->m_auditLogModifier.push_back(
|
||||
std::make_pair(mPartsAction, mParts));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -23,11 +23,12 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlAuditLogParts : public Action {
|
||||
class AuditLogParts : public Action {
|
||||
public:
|
||||
explicit CtlAuditLogParts(std::string action)
|
||||
explicit AuditLogParts(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
mPartsAction(0),
|
||||
mParts("") { }
|
||||
@ -40,6 +41,8 @@ class CtlAuditLogParts : public Action {
|
||||
std::string mParts;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_request_body_access.h"
|
||||
#include "actions/ctl/request_body_access.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -23,8 +23,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
bool CtlRequestBodyAccess::init(std::string *error) {
|
||||
|
||||
bool RequestBodyAccess::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 18, m_parser_payload.size() - 18);
|
||||
|
||||
if (what == "true") {
|
||||
@ -40,7 +42,7 @@ bool CtlRequestBodyAccess::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CtlRequestBodyAccess::evaluate(Rule *rule, Transaction *transaction) {
|
||||
bool RequestBodyAccess::evaluate(Rule *rule, Transaction *transaction) {
|
||||
if (m_request_body_access) {
|
||||
transaction->m_requestBodyAccess = RulesProperties::TrueConfigBoolean;
|
||||
} else {
|
||||
@ -50,5 +52,7 @@ bool CtlRequestBodyAccess::evaluate(Rule *rule, Transaction *transaction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -24,11 +24,12 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlRequestBodyAccess : public Action {
|
||||
class RequestBodyAccess : public Action {
|
||||
public:
|
||||
explicit CtlRequestBodyAccess(std::string action)
|
||||
explicit RequestBodyAccess(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
m_request_body_access(false) { }
|
||||
|
||||
@ -38,6 +39,8 @@ class CtlRequestBodyAccess : public Action {
|
||||
bool m_request_body_access;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_request_body_processor_json.h"
|
||||
#include "actions/ctl/request_body_processor_json.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -22,9 +22,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool CtlRequestBodyProcessorJSON::evaluate(Rule *rule,
|
||||
bool RequestBodyProcessorJSON::evaluate(Rule *rule,
|
||||
Transaction *transaction) {
|
||||
transaction->m_requestBodyProcessor = Transaction::JSONRequestBody;
|
||||
transaction->m_collections.store("REQBODY_PROCESSOR", "JSON");
|
||||
@ -33,5 +34,6 @@ bool CtlRequestBodyProcessorJSON::evaluate(Rule *rule,
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -23,16 +23,19 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlRequestBodyProcessorJSON : public Action {
|
||||
class RequestBodyProcessorJSON : public Action {
|
||||
public:
|
||||
explicit CtlRequestBodyProcessorJSON(std::string action)
|
||||
explicit RequestBodyProcessorJSON(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_request_body_processor_xml.h"
|
||||
#include "actions/ctl/request_body_processor_xml.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -22,9 +22,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool CtlRequestBodyProcessorXML::evaluate(Rule *rule,
|
||||
bool RequestBodyProcessorXML::evaluate(Rule *rule,
|
||||
Transaction *transaction) {
|
||||
transaction->m_requestBodyProcessor = Transaction::XMLRequestBody;
|
||||
transaction->m_collections.store("REQBODY_PROCESSOR", "XML");
|
||||
@ -33,5 +34,6 @@ bool CtlRequestBodyProcessorXML::evaluate(Rule *rule,
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -23,16 +23,19 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlRequestBodyProcessorXML : public Action {
|
||||
class RequestBodyProcessorXML : public Action {
|
||||
public:
|
||||
explicit CtlRequestBodyProcessorXML(std::string action)
|
||||
explicit RequestBodyProcessorXML(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_rule_remove_by_id.h"
|
||||
#include "actions/ctl/rule_remove_by_id.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -22,8 +22,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
bool CtlRuleRemoveById::init(std::string *error) {
|
||||
|
||||
bool RuleRemoveById::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 15, m_parser_payload.size() - 15);
|
||||
|
||||
try {
|
||||
@ -37,10 +39,12 @@ bool CtlRuleRemoveById::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CtlRuleRemoveById::evaluate(Rule *rule, Transaction *transaction) {
|
||||
bool RuleRemoveById::evaluate(Rule *rule, Transaction *transaction) {
|
||||
transaction->m_ruleRemoveById.push_back(m_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -24,11 +24,12 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlRuleRemoveById : public Action {
|
||||
class RuleRemoveById : public Action {
|
||||
public:
|
||||
explicit CtlRuleRemoveById(std::string action)
|
||||
explicit RuleRemoveById(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
@ -37,6 +38,8 @@ class CtlRuleRemoveById : public Action {
|
||||
int m_id;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_rule_remove_target_by_id.h"
|
||||
#include "actions/ctl/rule_remove_target_by_id.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -23,8 +23,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
bool CtlRuleRemoveTargetById::init(std::string *error) {
|
||||
|
||||
bool RuleRemoveTargetById::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 21, m_parser_payload.size() - 21);
|
||||
std::vector<std::string> param = split(what, ';');
|
||||
|
||||
@ -46,11 +48,13 @@ bool CtlRuleRemoveTargetById::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CtlRuleRemoveTargetById::evaluate(Rule *rule, Transaction *transaction) {
|
||||
bool RuleRemoveTargetById::evaluate(Rule *rule, Transaction *transaction) {
|
||||
transaction->m_ruleRemoveTargetById.push_back(
|
||||
std::make_pair(m_id, m_target));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -24,11 +24,12 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlRuleRemoveTargetById : public Action {
|
||||
class RuleRemoveTargetById : public Action {
|
||||
public:
|
||||
explicit CtlRuleRemoveTargetById(std::string action)
|
||||
explicit RuleRemoveTargetById(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
@ -38,6 +39,8 @@ class CtlRuleRemoveTargetById : public Action {
|
||||
std::string m_target;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl_rule_remove_target_by_tag.h"
|
||||
#include "actions/ctl/rule_remove_target_by_tag.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -23,8 +23,10 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
bool CtlRuleRemoveTargetByTag::init(std::string *error) {
|
||||
|
||||
bool RuleRemoveTargetByTag::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 22, m_parser_payload.size() - 22);
|
||||
std::vector<std::string> param = split(what, ';');
|
||||
|
||||
@ -39,11 +41,13 @@ bool CtlRuleRemoveTargetByTag::init(std::string *error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CtlRuleRemoveTargetByTag::evaluate(Rule *rule, Transaction *transaction) {
|
||||
bool RuleRemoveTargetByTag::evaluate(Rule *rule, Transaction *transaction) {
|
||||
transaction->m_ruleRemoveTargetByTag.push_back(
|
||||
std::make_pair(m_tag, m_target));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
@ -24,11 +24,12 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class CtlRuleRemoveTargetByTag : public Action {
|
||||
class RuleRemoveTargetByTag : public Action {
|
||||
public:
|
||||
explicit CtlRuleRemoveTargetByTag(std::string action)
|
||||
explicit RuleRemoveTargetByTag(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
@ -38,6 +39,8 @@ class CtlRuleRemoveTargetByTag : public Action {
|
||||
std::string m_target;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
@ -24,13 +24,13 @@ class Driver;
|
||||
#include "actions/action.h"
|
||||
#include "actions/allow.h"
|
||||
#include "actions/audit_log.h"
|
||||
#include "actions/ctl_audit_log_parts.h"
|
||||
#include "actions/ctl_request_body_access.h"
|
||||
#include "actions/ctl_request_body_processor_json.h"
|
||||
#include "actions/ctl_request_body_processor_xml.h"
|
||||
#include "actions/ctl_rule_remove_by_id.h"
|
||||
#include "actions/ctl_rule_remove_target_by_id.h"
|
||||
#include "actions/ctl_rule_remove_target_by_tag.h"
|
||||
#include "actions/ctl/audit_log_parts.h"
|
||||
#include "actions/ctl/request_body_access.h"
|
||||
#include "actions/ctl/request_body_processor_json.h"
|
||||
#include "actions/ctl/request_body_processor_xml.h"
|
||||
#include "actions/ctl/rule_remove_by_id.h"
|
||||
#include "actions/ctl/rule_remove_target_by_id.h"
|
||||
#include "actions/ctl/rule_remove_target_by_tag.h"
|
||||
#include "actions/init_col.h"
|
||||
#include "actions/log_data.h"
|
||||
#include "actions/maturity.h"
|
||||
@ -102,9 +102,9 @@ using modsecurity::Variables::XML;
|
||||
using modsecurity::actions::Accuracy;
|
||||
using modsecurity::actions::Action;
|
||||
using modsecurity::actions::Allow;
|
||||
using modsecurity::actions::CtlAuditLogParts;
|
||||
using modsecurity::actions::CtlRequestBodyProcessorJSON;
|
||||
using modsecurity::actions::CtlRequestBodyProcessorXML;
|
||||
using modsecurity::actions::ctl::AuditLogParts;
|
||||
using modsecurity::actions::ctl::RequestBodyProcessorJSON;
|
||||
using modsecurity::actions::ctl::RequestBodyProcessorXML;
|
||||
using modsecurity::actions::InitCol;
|
||||
using modsecurity::actions::LogData;
|
||||
using modsecurity::actions::Maturity;
|
||||
@ -1200,16 +1200,16 @@ act:
|
||||
}
|
||||
| ACTION_CTL_BDY_XML
|
||||
{
|
||||
$$ = new modsecurity::actions::CtlRequestBodyProcessorXML($1);
|
||||
$$ = new modsecurity::actions::ctl::RequestBodyProcessorXML($1);
|
||||
}
|
||||
| ACTION_CTL_BDY_JSON
|
||||
{
|
||||
$$ = new modsecurity::actions::CtlRequestBodyProcessorJSON($1);
|
||||
$$ = new modsecurity::actions::ctl::RequestBodyProcessorJSON($1);
|
||||
}
|
||||
| ACTION_CTL_RULE_REMOVE_TARGET_BY_TAG
|
||||
{
|
||||
std::string error;
|
||||
$$ = new modsecurity::actions::CtlRuleRemoveTargetByTag($1);
|
||||
$$ = new modsecurity::actions::ctl::RuleRemoveTargetByTag($1);
|
||||
if ($$->init(&error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
@ -1218,7 +1218,7 @@ act:
|
||||
| ACTION_CTL_RULE_REMOVE_TARGET_BY_ID
|
||||
{
|
||||
std::string error;
|
||||
$$ = new modsecurity::actions::CtlRuleRemoveTargetById($1);
|
||||
$$ = new modsecurity::actions::ctl::RuleRemoveTargetById($1);
|
||||
if ($$->init(&error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
@ -1227,7 +1227,7 @@ act:
|
||||
| ACTION_CTL_RULE_REMOVE_BY_ID
|
||||
{
|
||||
std::string error;
|
||||
$$ = new modsecurity::actions::CtlRuleRemoveById($1);
|
||||
$$ = new modsecurity::actions::ctl::RuleRemoveById($1);
|
||||
if ($$->init(&error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
@ -1236,7 +1236,7 @@ act:
|
||||
| ACTION_CTL_AUDIT_LOG_PARTS
|
||||
{
|
||||
std::string error;
|
||||
$$ = new CtlAuditLogParts($1);
|
||||
$$ = new AuditLogParts($1);
|
||||
if ($$->init(&error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
@ -1245,7 +1245,7 @@ act:
|
||||
| ACTION_CTL_REQUEST_BODY_ACCESS CONFIG_VALUE_ON
|
||||
{
|
||||
std::string error;
|
||||
$$ = new modsecurity::actions::CtlRequestBodyAccess($1 + "true");
|
||||
$$ = new modsecurity::actions::ctl::RequestBodyAccess($1 + "true");
|
||||
if ($$->init(&error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
@ -1254,7 +1254,7 @@ act:
|
||||
| ACTION_CTL_REQUEST_BODY_ACCESS CONFIG_VALUE_OFF
|
||||
{
|
||||
std::string error;
|
||||
$$ = new modsecurity::actions::CtlRequestBodyAccess($1 + "false");
|
||||
$$ = new modsecurity::actions::ctl::RequestBodyAccess($1 + "false");
|
||||
if ($$->init(&error) == false) {
|
||||
driver.error(@0, error);
|
||||
YYERROR;
|
||||
|
Loading…
x
Reference in New Issue
Block a user