Refactoring: Having RuleMarker in a separated file

This commit is contained in:
Felipe Zimmerle
2019-02-19 14:34:20 -03:00
parent bdedfd2463
commit 8274be066a
4 changed files with 80 additions and 37 deletions

View File

@@ -29,7 +29,6 @@
#include "modsecurity/modsecurity.h"
#include "modsecurity/variable_value.h"
#ifdef __cplusplus
namespace modsecurity {
@@ -103,42 +102,6 @@ class Rule {
};
class RuleMarker : public Rule {
public:
RuleMarker(
const std::string &name,
std::unique_ptr<std::string> fileName,
int lineNumber)
: Rule(std::move(fileName), lineNumber),
m_name(std::make_shared<std::string>(name)) { }
virtual bool evaluate(Transaction *transaction,
std::shared_ptr<RuleMessage> rm) override {
if (transaction->isInsideAMarker()) {
if (*transaction->getCurrentMarker() == *m_name) {
transaction->removeMarker();
// FIXME: Move this to .cc
// ms_dbg_a(transaction, 4, "Out of a SecMarker " + *m_name);
}
}
return true;
};
std::shared_ptr<std::string> getName() const {
return m_name;
}
bool isMarker() override { return true; }
private:
std::shared_ptr<std::string> m_name;
};
class RuleWithActions : public Rule {
public:
RuleWithActions(