From da38f20e19f4d3fd8e7371b42cb52b95699dae6c Mon Sep 17 00:00:00 2001 From: Eduardo Arias Date: Sun, 28 Apr 2024 22:25:17 -0300 Subject: [PATCH] Added missing override keyword as reported by cppcheck 2.14 --- src/actions/exec.h | 5 +---- src/collection/backend/in_memory-per_process.h | 2 +- src/operators/fuzzy_hash.h | 2 +- src/operators/pm.h | 2 +- src/operators/rx.h | 2 +- src/operators/rx_global.h | 2 +- src/operators/validate_dtd.h | 2 -- src/operators/validate_schema.h | 1 - src/operators/verify_cc.h | 2 +- src/operators/verify_cpf.h | 11 +++-------- src/operators/verify_ssn.h | 11 +++-------- src/operators/verify_svnr.h | 11 +++-------- 12 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/actions/exec.h b/src/actions/exec.h index f8999821..d1f42f85 100644 --- a/src/actions/exec.h +++ b/src/actions/exec.h @@ -31,10 +31,7 @@ namespace actions { class Exec : public Action { public: explicit Exec(const std::string &action) - : Action(action), - m_script("") { } - - ~Exec() { } + : Action(action) { } bool evaluate(RuleWithActions *rule, Transaction *transaction) override; bool init(std::string *error) override; diff --git a/src/collection/backend/in_memory-per_process.h b/src/collection/backend/in_memory-per_process.h index 2e283d25..4aa7b1d0 100644 --- a/src/collection/backend/in_memory-per_process.h +++ b/src/collection/backend/in_memory-per_process.h @@ -74,7 +74,7 @@ class InMemoryPerProcess : public Collection { public: explicit InMemoryPerProcess(const std::string &name); - ~InMemoryPerProcess(); + ~InMemoryPerProcess() override; void store(const std::string &key, const std::string &value); bool storeOrUpdateFirst(const std::string &key, diff --git a/src/operators/fuzzy_hash.h b/src/operators/fuzzy_hash.h index b555eff5..10a0ca6d 100644 --- a/src/operators/fuzzy_hash.h +++ b/src/operators/fuzzy_hash.h @@ -42,7 +42,7 @@ class FuzzyHash : public Operator { : Operator("FuzzyHash", std::move(param)), m_threshold(0), m_head(NULL) { } - ~FuzzyHash(); + ~FuzzyHash() override; bool evaluate(Transaction *transaction, const std::string &std) override; diff --git a/src/operators/pm.h b/src/operators/pm.h index 1b45fff7..3ac1ffec 100644 --- a/src/operators/pm.h +++ b/src/operators/pm.h @@ -40,7 +40,7 @@ class Pm : public Operator { : Operator(n, std::move(param)) { m_p = acmp_create(0); } - ~Pm(); + ~Pm() override; bool evaluate(Transaction *transaction, RuleWithActions *rule, const std::string &str, RuleMessage &ruleMessage) override; diff --git a/src/operators/rx.h b/src/operators/rx.h index 86a12d52..bc089690 100644 --- a/src/operators/rx.h +++ b/src/operators/rx.h @@ -42,7 +42,7 @@ class Rx : public Operator { m_couldContainsMacro = true; } - ~Rx() { + ~Rx() override { if (m_string->m_containsMacro == false && m_re != NULL) { delete m_re; m_re = NULL; diff --git a/src/operators/rx_global.h b/src/operators/rx_global.h index 5b6ed875..82684eea 100644 --- a/src/operators/rx_global.h +++ b/src/operators/rx_global.h @@ -42,7 +42,7 @@ class RxGlobal : public Operator { m_couldContainsMacro = true; } - ~RxGlobal() { + ~RxGlobal() override { if (m_string->m_containsMacro == false && m_re != NULL) { delete m_re; m_re = NULL; diff --git a/src/operators/validate_dtd.h b/src/operators/validate_dtd.h index 9de1ea1d..d35d7b35 100644 --- a/src/operators/validate_dtd.h +++ b/src/operators/validate_dtd.h @@ -57,8 +57,6 @@ class ValidateDTD : public Operator { explicit ValidateDTD(std::unique_ptr param) : Operator("ValidateDTD", std::move(param)) { } #ifdef WITH_LIBXML2 - ~ValidateDTD() { } - bool evaluate(Transaction *transaction, const std::string &str) override; bool init(const std::string &file, std::string *error) override; diff --git a/src/operators/validate_schema.h b/src/operators/validate_schema.h index 02f07e4d..f681b853 100644 --- a/src/operators/validate_schema.h +++ b/src/operators/validate_schema.h @@ -38,7 +38,6 @@ class ValidateSchema : public Operator { /** @ingroup ModSecurity_Operator */ explicit ValidateSchema(std::unique_ptr param) : Operator("ValidateSchema", std::move(param)) { } - ~ValidateSchema() { } #ifdef WITH_LIBXML2 bool evaluate(Transaction *transaction, const std::string &str) override; diff --git a/src/operators/verify_cc.h b/src/operators/verify_cc.h index e14f728a..05d4cdec 100644 --- a/src/operators/verify_cc.h +++ b/src/operators/verify_cc.h @@ -45,7 +45,7 @@ class VerifyCC : public Operator { m_pc(NULL), m_pce(NULL) { } #endif - ~VerifyCC(); + ~VerifyCC() override; bool evaluate(Transaction *t, RuleWithActions *rule, const std::string& input, diff --git a/src/operators/verify_cpf.h b/src/operators/verify_cpf.h index ccb9988d..a4ff4c22 100644 --- a/src/operators/verify_cpf.h +++ b/src/operators/verify_cpf.h @@ -35,13 +35,8 @@ class VerifyCPF : public Operator { public: /** @ingroup ModSecurity_Operator */ explicit VerifyCPF(std::unique_ptr param) - : Operator("VerifyCPF", std::move(param)) { - m_re = new Regex(m_param); - } - - ~VerifyCPF() { - delete m_re; - } + : Operator("VerifyCPF", std::move(param)) + , m_re(std::make_unique(m_param)) { } bool operator=(const VerifyCPF &a) = delete; VerifyCPF(const VerifyCPF &a) = delete; @@ -54,7 +49,7 @@ class VerifyCPF : public Operator { private: static int convert_to_int(const char c); - Regex *m_re; + std::unique_ptr m_re; const char bad_cpf[12][12] = { "00000000000", "01234567890", "11111111111", diff --git a/src/operators/verify_ssn.h b/src/operators/verify_ssn.h index 7bb40c33..5b54492b 100644 --- a/src/operators/verify_ssn.h +++ b/src/operators/verify_ssn.h @@ -35,13 +35,8 @@ class VerifySSN : public Operator { public: /** @ingroup ModSecurity_Operator */ explicit VerifySSN(std::unique_ptr param) - : Operator("VerifySSN", std::move(param)) { - m_re = new Regex(m_param); - } - - ~VerifySSN() { - delete m_re; - } + : Operator("VerifySSN", std::move(param)) + , m_re(std::make_unique(m_param)) { } bool operator=(const VerifySSN &a) = delete; VerifySSN(const VerifySSN &a) = delete; @@ -56,7 +51,7 @@ class VerifySSN : public Operator { static bool verify(const char *ssnumber, int len); static int convert_to_int(const char c); - Regex *m_re; + std::unique_ptr m_re; }; } // namespace operators diff --git a/src/operators/verify_svnr.h b/src/operators/verify_svnr.h index ba435834..aad3d791 100644 --- a/src/operators/verify_svnr.h +++ b/src/operators/verify_svnr.h @@ -21,13 +21,8 @@ class VerifySVNR : public Operator { public: /** @ingroup ModSecurity_Operator */ explicit VerifySVNR(std::unique_ptr param) - : Operator("VerifySVNR", std::move(param)) { - m_re = new Regex(m_param); - } - - ~VerifySVNR() { - delete m_re; - } + : Operator("VerifySVNR", std::move(param)) + , m_re(std::make_unique(m_param)) { } bool operator=(const VerifySVNR &a) = delete; VerifySVNR(const VerifySVNR &a) = delete; @@ -39,7 +34,7 @@ class VerifySVNR : public Operator { bool verify(const char *ssnumber, int len); private: - Regex *m_re; + std::unique_ptr m_re; static int convert_to_int(const char c); const char bad_svnr[12][11] = { "0000000000", "0123456789",