mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-01 03:57:47 +03:00
Refactoring: moves ctl_ actions into ctl namespace
This commit is contained in:
49
src/actions/ctl/audit_log_parts.cc
Normal file
49
src/actions/ctl/audit_log_parts.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/audit_log_parts.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
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 == "+") {
|
||||
mPartsAction = 0;
|
||||
} else {
|
||||
mPartsAction = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
49
src/actions/ctl/audit_log_parts.h
Normal file
49
src/actions/ctl/audit_log_parts.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_AUDIT_LOG_PARTS_H_
|
||||
#define SRC_ACTIONS_CTL_AUDIT_LOG_PARTS_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class AuditLogParts : public Action {
|
||||
public:
|
||||
explicit AuditLogParts(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
mPartsAction(0),
|
||||
mParts("") { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
protected:
|
||||
int mPartsAction;
|
||||
std::string mParts;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_AUDIT_LOG_PARTS_H_
|
58
src/actions/ctl/request_body_access.cc
Normal file
58
src/actions/ctl/request_body_access.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/request_body_access.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/rules_properties.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RequestBodyAccess::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 18, m_parser_payload.size() - 18);
|
||||
|
||||
if (what == "true") {
|
||||
m_request_body_access = true;
|
||||
} else if (what == "false") {
|
||||
m_request_body_access = false;
|
||||
} else {
|
||||
error->assign("Internal error. Expected: true or false, got: " \
|
||||
+ m_parser_payload);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RequestBodyAccess::evaluate(Rule *rule, Transaction *transaction) {
|
||||
if (m_request_body_access) {
|
||||
transaction->m_requestBodyAccess = RulesProperties::TrueConfigBoolean;
|
||||
} else {
|
||||
transaction->m_requestBodyAccess = RulesProperties::FalseConfigBoolean;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
47
src/actions/ctl/request_body_access.h
Normal file
47
src/actions/ctl/request_body_access.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_REQUEST_BODY_ACCESS_H_
|
||||
#define SRC_ACTIONS_CTL_REQUEST_BODY_ACCESS_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class RequestBodyAccess : public Action {
|
||||
public:
|
||||
explicit RequestBodyAccess(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
m_request_body_access(false) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
|
||||
bool m_request_body_access;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_REQUEST_BODY_ACCESS_H_
|
39
src/actions/ctl/request_body_processor_json.cc
Normal file
39
src/actions/ctl/request_body_processor_json.cc
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/request_body_processor_json.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RequestBodyProcessorJSON::evaluate(Rule *rule,
|
||||
Transaction *transaction) {
|
||||
transaction->m_requestBodyProcessor = Transaction::JSONRequestBody;
|
||||
transaction->m_collections.store("REQBODY_PROCESSOR", "JSON");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
42
src/actions/ctl/request_body_processor_json.h
Normal file
42
src/actions/ctl/request_body_processor_json.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_REQUEST_BODY_PROCESSOR_JSON_H_
|
||||
#define SRC_ACTIONS_CTL_REQUEST_BODY_PROCESSOR_JSON_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class RequestBodyProcessorJSON : public Action {
|
||||
public:
|
||||
explicit RequestBodyProcessorJSON(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_REQUEST_BODY_PROCESSOR_JSON_H_
|
39
src/actions/ctl/request_body_processor_xml.cc
Normal file
39
src/actions/ctl/request_body_processor_xml.cc
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/request_body_processor_xml.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RequestBodyProcessorXML::evaluate(Rule *rule,
|
||||
Transaction *transaction) {
|
||||
transaction->m_requestBodyProcessor = Transaction::XMLRequestBody;
|
||||
transaction->m_collections.store("REQBODY_PROCESSOR", "XML");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
42
src/actions/ctl/request_body_processor_xml.h
Normal file
42
src/actions/ctl/request_body_processor_xml.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_REQUEST_BODY_PROCESSOR_XML_H_
|
||||
#define SRC_ACTIONS_CTL_REQUEST_BODY_PROCESSOR_XML_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class RequestBodyProcessorXML : public Action {
|
||||
public:
|
||||
explicit RequestBodyProcessorXML(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_REQUEST_BODY_PROCESSOR_XML_H_
|
50
src/actions/ctl/rule_remove_by_id.cc
Normal file
50
src/actions/ctl/rule_remove_by_id.cc
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/rule_remove_by_id.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool RuleRemoveById::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 15, m_parser_payload.size() - 15);
|
||||
|
||||
try {
|
||||
m_id = std::stoi(what);
|
||||
} catch(...) {
|
||||
error->assign("Not able to convert '" + what +
|
||||
"' into a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuleRemoveById::evaluate(Rule *rule, Transaction *transaction) {
|
||||
transaction->m_ruleRemoveById.push_back(m_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
46
src/actions/ctl/rule_remove_by_id.h
Normal file
46
src/actions/ctl/rule_remove_by_id.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_RULE_REMOVE_BY_ID_H_
|
||||
#define SRC_ACTIONS_CTL_RULE_REMOVE_BY_ID_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class RuleRemoveById : public Action {
|
||||
public:
|
||||
explicit RuleRemoveById(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
|
||||
int m_id;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_RULE_REMOVE_BY_ID_H_
|
60
src/actions/ctl/rule_remove_target_by_id.cc
Normal file
60
src/actions/ctl/rule_remove_target_by_id.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/rule_remove_target_by_id.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
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, ';');
|
||||
|
||||
if (param.size() < 2) {
|
||||
error->assign(what + " is not a valid `ID;VARIABLE'");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
m_id = std::stoi(param[0]);
|
||||
} catch(...) {
|
||||
error->assign("Not able to convert '" + param[0] +
|
||||
"' into a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_target = param[1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
47
src/actions/ctl/rule_remove_target_by_id.h
Normal file
47
src/actions/ctl/rule_remove_target_by_id.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_RULE_REMOVE_TARGET_BY_ID_H_
|
||||
#define SRC_ACTIONS_CTL_RULE_REMOVE_TARGET_BY_ID_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class RuleRemoveTargetById : public Action {
|
||||
public:
|
||||
explicit RuleRemoveTargetById(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
|
||||
int m_id;
|
||||
std::string m_target;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_RULE_REMOVE_TARGET_BY_ID_H_
|
53
src/actions/ctl/rule_remove_target_by_tag.cc
Normal file
53
src/actions/ctl/rule_remove_target_by_tag.cc
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "actions/ctl/rule_remove_target_by_tag.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
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, ';');
|
||||
|
||||
if (param.size() < 2) {
|
||||
error->assign(what + " is not a valid `TAG;VARIABLE'");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_tag = param[0];
|
||||
m_target = param[1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
47
src/actions/ctl/rule_remove_target_by_tag.h
Normal file
47
src/actions/ctl/rule_remove_target_by_tag.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_RULE_REMOVE_TARGET_BY_TAG_H_
|
||||
#define SRC_ACTIONS_CTL_RULE_REMOVE_TARGET_BY_TAG_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class RuleRemoveTargetByTag : public Action {
|
||||
public:
|
||||
explicit RuleRemoveTargetByTag(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
|
||||
std::string m_tag;
|
||||
std::string m_target;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_RULE_REMOVE_TARGET_BY_TAG_H_
|
Reference in New Issue
Block a user