Delete unused copy constructor & assignment operator in Rule, RuleMarker & Action

- Declare other unsupported copy constructor & assignment operators as
  deleted too (RuleWithActions, RuleUnconditional & RuleScript)
This commit is contained in:
Eduardo Arias
2024-06-02 02:03:34 +00:00
parent f180e647a1
commit 2ec640fd76
7 changed files with 37 additions and 147 deletions

View File

@@ -13,15 +13,6 @@
*
*/
#ifdef __cplusplus
#include <stack>
#include <vector>
#include <string>
#include <list>
#include <memory>
#include <utility>
#endif
#ifndef HEADERS_MODSECURITY_RULE_MARKER_H_
#define HEADERS_MODSECURITY_RULE_MARKER_H_
@@ -32,6 +23,9 @@
#ifdef __cplusplus
#include <string>
#include <memory>
namespace modsecurity {
@@ -42,45 +36,32 @@ class RuleMarker : public Rule {
std::unique_ptr<std::string> fileName,
int lineNumber)
: Rule(std::move(fileName), lineNumber),
m_name(std::make_shared<std::string>(name)) { }
m_name(name) { }
RuleMarker(const RuleMarker& r) :
Rule(r),
m_name(r.m_name)
{ }
RuleMarker &operator =(const RuleMarker& r) {
Rule::operator = (r);
m_name = r.m_name;
return *this;
}
RuleMarker(const RuleMarker &r) = delete;
RuleMarker &operator=(const RuleMarker &r) = delete;
virtual bool evaluate(Transaction *transaction,
std::shared_ptr<RuleMessage> rm) override {
return evaluate(transaction);
}
virtual bool evaluate(Transaction *transaction) override {
if (transaction->isInsideAMarker()) {
if (*transaction->getCurrentMarker() == *m_name) {
if (transaction->isInsideAMarker() &&
*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() {
return m_name;
}
bool isMarker() override { return true; }
private:
std::shared_ptr<std::string> m_name;
const std::string m_name;
};