mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Use initialization list to initialize m_service
- This is correct because base class is initialized before members are initialized. - Removes cppcheck suppression by addressing reported issue. - Leverage C++11's 'default member initializer' to initialize m_provider & m_demandsPassword and address Sonarcloud issue.
This commit is contained in:
parent
b0497d9cb9
commit
ce9a3167fa
@ -33,8 +33,8 @@
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
namespace modsecurity::operators {
|
||||
|
||||
|
||||
class Rbl : public Operator {
|
||||
public:
|
||||
@ -66,21 +66,18 @@ class Rbl : public Operator {
|
||||
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
explicit Rbl(std::unique_ptr<RunTimeString> param)
|
||||
: m_service(),
|
||||
m_demandsPassword(false),
|
||||
m_provider(RblProvider::UnknownProvider),
|
||||
Operator("Rbl", std::move(param)) {
|
||||
m_service = m_string->evaluate(); // cppcheck-suppress useInitializationList
|
||||
: Operator("Rbl", std::move(param)),
|
||||
m_service(m_string->evaluate()) {
|
||||
if (m_service.find("httpbl.org") != std::string::npos)
|
||||
{
|
||||
m_demandsPassword = true;
|
||||
m_provider = RblProvider::httpbl;
|
||||
} else if (m_service.find("uribl.com") != std::string::npos) {
|
||||
m_provider = RblProvider::uribl;
|
||||
} else if (m_service.find("spamhaus.org") != std::string::npos) {
|
||||
m_provider = RblProvider::spamhaus;
|
||||
}
|
||||
} else if (m_service.find("uribl.com") != std::string::npos) {
|
||||
m_provider = RblProvider::uribl;
|
||||
} else if (m_service.find("spamhaus.org") != std::string::npos) {
|
||||
m_provider = RblProvider::spamhaus;
|
||||
}
|
||||
}
|
||||
bool evaluate(Transaction *transaction, RuleWithActions *rule,
|
||||
const std::string& input,
|
||||
RuleMessage &ruleMessage) override;
|
||||
@ -98,12 +95,12 @@ class Rbl : public Operator {
|
||||
|
||||
private:
|
||||
std::string m_service;
|
||||
bool m_demandsPassword;
|
||||
RblProvider m_provider;
|
||||
bool m_demandsPassword = false;
|
||||
RblProvider m_provider = RblProvider::UnknownProvider;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
} // namespace modsecurity::operators
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_RBL_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user