From 8fa0523fe09f34f85b8573f54e0d34e552ca3f20 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Mon, 28 Nov 2016 09:55:48 -0300 Subject: [PATCH] Adds initial support to the multiMatch action --- src/Makefile.am | 1 + src/actions/action.cc | 6 ++++- src/actions/multi_match.cc | 34 ++++++++++++++++++++++++++++ src/actions/multi_match.h | 45 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/actions/multi_match.cc create mode 100644 src/actions/multi_match.h diff --git a/src/Makefile.am b/src/Makefile.am index de163212..6cb628e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,6 +104,7 @@ ACTIONS = \ actions/log_data.cc \ actions/maturity.cc \ actions/msg.cc \ + actions/multi_match.cc \ actions/no_audit_log.cc \ actions/no_log.cc \ actions/pass.cc \ diff --git a/src/actions/action.cc b/src/actions/action.cc index 386ce509..5ae116d0 100644 --- a/src/actions/action.cc +++ b/src/actions/action.cc @@ -20,6 +20,7 @@ #include "modsecurity/transaction.h" #include "modsecurity/rule.h" +#include "src/utils/string.h" #include "src/actions/block.h" #include "src/actions/chain.h" @@ -33,7 +34,7 @@ #include "src/actions/pass.h" #include "src/actions/log.h" #include "src/actions/no_log.h" - +#include "src/actions/multi_match.h" #define IF_MATCH(a) \ @@ -97,6 +98,9 @@ Action *Action::instantiate(const std::string& name) { if (name == "nolog") { return new NoLog(name); } + if (utils::string::tolower(name) == "multimatch") { + return new MultiMatch(utils::string::tolower(name)); + } return new Action(name); } diff --git a/src/actions/multi_match.cc b/src/actions/multi_match.cc new file mode 100644 index 00000000..6bf785a2 --- /dev/null +++ b/src/actions/multi_match.cc @@ -0,0 +1,34 @@ +/* + * 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 "src/actions/multi_match.h" + +#include +#include + +#include "modsecurity/transaction.h" +#include "modsecurity/rule.h" + +namespace modsecurity { +namespace actions { + + +bool MultiMatch::evaluate(Rule *rule, Transaction *transaction) { + return true; +} + + +} // namespace actions +} // namespace modsecurity diff --git a/src/actions/multi_match.h b/src/actions/multi_match.h new file mode 100644 index 00000000..6f74a414 --- /dev/null +++ b/src/actions/multi_match.h @@ -0,0 +1,45 @@ +/* + * 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 + +#include "modsecurity/actions/action.h" + +#ifndef SRC_ACTIONS_MULTI_MATCH_H_ +#define SRC_ACTIONS_MULTI_MATCH_H_ + +#ifdef __cplusplus +class Transaction; + +namespace modsecurity { +class Transaction; +class Rule; + +namespace actions { + + +class MultiMatch : public Action { + public: + explicit MultiMatch(std::string action) + : Action(action, RunTimeOnlyIfMatchKind) { } + + bool evaluate(Rule *rule, Transaction *transaction) override; +}; + +} // namespace actions +} // namespace modsecurity +#endif + +#endif // SRC_ACTIONS_MULTI_MATCH_H_