mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 13:26:01 +03:00
Cosmetics: address cppcheck warnings on src/variables
This commit is contained in:
parent
ff9152ed74
commit
68ef2dece3
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class Duration : public Variable {
|
||||
public:
|
||||
explicit Duration(std::string _name)
|
||||
explicit Duration(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("DURATION") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class Env : public Variable {
|
||||
public:
|
||||
explicit Env(std::string _name)
|
||||
explicit Env(const std::string &_name)
|
||||
: Variable(_name) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class Global_DictElement : public Variable {
|
||||
public:
|
||||
explicit Global_DictElement(std::string dictElement)
|
||||
explicit Global_DictElement(const std::string &dictElement)
|
||||
: Variable("GLOBAL:" + dictElement),
|
||||
m_dictElement("GLOBAL:" + dictElement) { }
|
||||
|
||||
@ -67,7 +67,7 @@ class Global_NoDictElement : public Variable {
|
||||
|
||||
class Global_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit Global_DictElementRegexp(std::string dictElement)
|
||||
explicit Global_DictElementRegexp(const std::string &dictElement)
|
||||
: VariableRegex("GLOBAL", dictElement),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
@ -100,13 +100,13 @@ class Global_DynamicElement : public Variable {
|
||||
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
|
||||
}
|
||||
|
||||
void del(Transaction *t, std::string k) {
|
||||
static void del(Transaction *t, const std::string &k) {
|
||||
t->m_collections.m_global_collection->del(k,
|
||||
t->m_collections.m_global_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value);
|
||||
}
|
||||
|
||||
void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
static void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
std::string value) {
|
||||
t->m_collections.m_global_collection->storeOrUpdateFirst(
|
||||
var, t->m_collections.m_global_collection_key,
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class HighestSeverity : public Variable {
|
||||
public:
|
||||
explicit HighestSeverity(std::string _name)
|
||||
explicit HighestSeverity(const std::string &_name)
|
||||
: Variable(_name)
|
||||
{ }
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class Ip_DictElement : public Variable {
|
||||
public:
|
||||
explicit Ip_DictElement(std::string dictElement)
|
||||
explicit Ip_DictElement(const std::string &dictElement)
|
||||
: Variable("IP:" + dictElement),
|
||||
m_dictElement("IP:" + dictElement) { }
|
||||
|
||||
@ -67,7 +67,7 @@ class Ip_NoDictElement : public Variable {
|
||||
|
||||
class Ip_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit Ip_DictElementRegexp(std::string dictElement)
|
||||
explicit Ip_DictElementRegexp(const std::string &dictElement)
|
||||
: VariableRegex("IP", dictElement),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
@ -99,14 +99,14 @@ class Ip_DynamicElement : public Variable {
|
||||
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
|
||||
}
|
||||
|
||||
void del(Transaction *t, std::string k) {
|
||||
static void del(Transaction *t, const std::string &k) {
|
||||
t->m_collections.m_ip_collection->del(k,
|
||||
t->m_collections.m_ip_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value);
|
||||
}
|
||||
|
||||
void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
std::string value) {
|
||||
static void storeOrUpdateFirst(Transaction *t, const std::string &var,
|
||||
const std::string &value) {
|
||||
t->m_collections.m_ip_collection->storeOrUpdateFirst(
|
||||
var, t->m_collections.m_ip_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value,
|
||||
|
@ -32,7 +32,7 @@ namespace variables {
|
||||
|
||||
class ModsecBuild : public Variable {
|
||||
public:
|
||||
explicit ModsecBuild(std::string _name)
|
||||
explicit ModsecBuild(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("MODSEC_BUILD") {
|
||||
std::ostringstream ss;
|
||||
|
@ -32,7 +32,7 @@ namespace variables {
|
||||
|
||||
class RemoteUser : public Variable {
|
||||
public:
|
||||
explicit RemoteUser(std::string _name)
|
||||
explicit RemoteUser(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("REMOTE_USER") { }
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class Resource_DictElement : public Variable {
|
||||
public:
|
||||
explicit Resource_DictElement(std::string dictElement)
|
||||
explicit Resource_DictElement(const std::string &dictElement)
|
||||
: Variable("RESOURCE:" + dictElement),
|
||||
m_dictElement("RESOURCE:" + dictElement) { }
|
||||
|
||||
@ -67,7 +67,7 @@ class Resource_NoDictElement : public Variable {
|
||||
|
||||
class Resource_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit Resource_DictElementRegexp(std::string dictElement)
|
||||
explicit Resource_DictElementRegexp(const std::string &dictElement)
|
||||
: VariableRegex("RESOURCE:", dictElement),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
@ -99,14 +99,14 @@ class Resource_DynamicElement : public Variable {
|
||||
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
|
||||
}
|
||||
|
||||
void del(Transaction *t, std::string k) {
|
||||
static void del(Transaction *t, const std::string &k) {
|
||||
t->m_collections.m_resource_collection->del(k,
|
||||
t->m_collections.m_resource_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value);
|
||||
}
|
||||
|
||||
void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
std::string value) {
|
||||
static void storeOrUpdateFirst(Transaction *t, const std::string &var,
|
||||
const std::string &value) {
|
||||
t->m_collections.m_resource_collection->storeOrUpdateFirst(
|
||||
var, t->m_collections.m_resource_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value, value);
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class Rule_DictElement : public VariableDictElement { \
|
||||
public:
|
||||
explicit Rule_DictElement(std::string dictElement)
|
||||
explicit Rule_DictElement(const std::string &dictElement)
|
||||
: VariableDictElement(std::string("RULE"), dictElement) { }
|
||||
|
||||
static void id(Transaction *t,
|
||||
@ -194,7 +194,7 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
|
||||
class Rule_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit Rule_DictElementRegexp(std::string regex)
|
||||
explicit Rule_DictElementRegexp(const std::string ®ex)
|
||||
: VariableRegex("RULE", regex) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class Session_DictElement : public Variable {
|
||||
public:
|
||||
explicit Session_DictElement(std::string dictElement)
|
||||
explicit Session_DictElement(const std::string &dictElement)
|
||||
: Variable("SESSION:" + dictElement),
|
||||
m_dictElement("SESSION:" + dictElement) { }
|
||||
|
||||
@ -67,7 +67,7 @@ class Session_NoDictElement : public Variable {
|
||||
|
||||
class Session_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit Session_DictElementRegexp(std::string dictElement)
|
||||
explicit Session_DictElementRegexp(const std::string &dictElement)
|
||||
: VariableRegex("SESSION", dictElement),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
@ -99,14 +99,14 @@ class Session_DynamicElement : public Variable {
|
||||
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
|
||||
}
|
||||
|
||||
void del(Transaction *t, std::string k) {
|
||||
static void del(Transaction *t, const std::string &k) {
|
||||
t->m_collections.m_session_collection->del(k,
|
||||
t->m_collections.m_session_collection_key,
|
||||
t->m_collections.m_ip_collection_key);
|
||||
}
|
||||
|
||||
void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
std::string value) {
|
||||
static void storeOrUpdateFirst(Transaction *t, const std::string &var,
|
||||
const std::string &value) {
|
||||
t->m_collections.m_session_collection->storeOrUpdateFirst(
|
||||
var, t->m_collections.m_session_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value,
|
||||
|
@ -31,7 +31,7 @@ namespace variables {
|
||||
|
||||
class Time : public Variable {
|
||||
public:
|
||||
explicit Time(std::string _name)
|
||||
explicit Time(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeDay : public Variable {
|
||||
public:
|
||||
explicit TimeDay(std::string _name)
|
||||
explicit TimeDay(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_DAY") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeEpoch : public Variable {
|
||||
public:
|
||||
explicit TimeEpoch(std::string _name)
|
||||
explicit TimeEpoch(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_EPOCH") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeHour : public Variable {
|
||||
public:
|
||||
explicit TimeHour(std::string _name)
|
||||
explicit TimeHour(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_HOUR") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeMin : public Variable {
|
||||
public:
|
||||
explicit TimeMin(std::string _name)
|
||||
explicit TimeMin(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_MIN") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeMon : public Variable {
|
||||
public:
|
||||
explicit TimeMon(std::string _name)
|
||||
explicit TimeMon(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_MON") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeSec : public Variable {
|
||||
public:
|
||||
explicit TimeSec(std::string _name)
|
||||
explicit TimeSec(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_SEC") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeWDay : public Variable {
|
||||
public:
|
||||
explicit TimeWDay(std::string _name)
|
||||
explicit TimeWDay(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_WDAY") { }
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace variables {
|
||||
|
||||
class TimeYear : public Variable {
|
||||
public:
|
||||
explicit TimeYear(std::string _name)
|
||||
explicit TimeYear(const std::string &_name)
|
||||
: Variable(_name),
|
||||
m_retName("TIME_YEAR") { }
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class Tx_DictElement : public Variable {
|
||||
public:
|
||||
explicit Tx_DictElement(std::string dictElement)
|
||||
explicit Tx_DictElement(const std::string &dictElement)
|
||||
: Variable("TX:" + dictElement),
|
||||
m_dictElement("TX:" + dictElement) { }
|
||||
|
||||
@ -65,7 +65,7 @@ class Tx_NoDictElement : public Variable {
|
||||
|
||||
class Tx_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit Tx_DictElementRegexp(std::string dictElement)
|
||||
explicit Tx_DictElementRegexp(const std::string &dictElement)
|
||||
: VariableRegex("TX", dictElement),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
@ -94,11 +94,11 @@ class Tx_DynamicElement : public Variable {
|
||||
m_keyExclusion);
|
||||
}
|
||||
|
||||
void del(Transaction *t, std::string k) {
|
||||
static void del(Transaction *t, const std::string &k) {
|
||||
t->m_collections.m_tx_collection->del(k);
|
||||
}
|
||||
|
||||
void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
static void storeOrUpdateFirst(Transaction *t, const std::string &var,
|
||||
std::string value) {
|
||||
t->m_collections.m_tx_collection->storeOrUpdateFirst(var, value);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace variables {
|
||||
|
||||
class User_DictElement : public Variable {
|
||||
public:
|
||||
explicit User_DictElement(std::string dictElement)
|
||||
explicit User_DictElement(const std::string &dictElement)
|
||||
: Variable("USER:" + dictElement),
|
||||
m_dictElement("USER:" + dictElement) { }
|
||||
|
||||
@ -67,7 +67,7 @@ class User_NoDictElement : public Variable {
|
||||
|
||||
class User_DictElementRegexp : public VariableRegex {
|
||||
public:
|
||||
explicit User_DictElementRegexp(std::string dictElement)
|
||||
explicit User_DictElementRegexp(const std::string &dictElement)
|
||||
: VariableRegex("USER", dictElement),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
@ -99,14 +99,14 @@ class User_DynamicElement : public Variable {
|
||||
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
|
||||
}
|
||||
|
||||
void del(Transaction *t, std::string k) {
|
||||
static void del(Transaction *t, const std::string &k) {
|
||||
t->m_collections.m_user_collection->del(k,
|
||||
t->m_collections.m_user_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value);
|
||||
}
|
||||
|
||||
void storeOrUpdateFirst(Transaction *t, std::string var,
|
||||
std::string value) {
|
||||
static void storeOrUpdateFirst(Transaction *t, const std::string &var,
|
||||
const std::string &value) {
|
||||
t->m_collections.m_user_collection->storeOrUpdateFirst(
|
||||
var, t->m_collections.m_user_collection_key,
|
||||
t->m_rules->m_secWebAppId.m_value,
|
||||
|
@ -45,7 +45,7 @@
|
||||
#define VAR_WITH_REGEX(n, N, e) \
|
||||
class n ## _DictElementRegexp : public VariableRegex { \
|
||||
public: \
|
||||
explicit n ## _DictElementRegexp(std::string regex) \
|
||||
explicit n ## _DictElementRegexp(const std::string ®ex) \
|
||||
: VariableRegex(#N, regex) { } \
|
||||
\
|
||||
void evaluate(Transaction *transaction, \
|
||||
@ -60,7 +60,7 @@ class n ## _DictElementRegexp : public VariableRegex { \
|
||||
#define VAR_WITH_DICT_ELEMENT(n, N, e) \
|
||||
class n ## _DictElement : public VariableDictElement { \
|
||||
public: \
|
||||
explicit n ## _DictElement(std::string dictElement) \
|
||||
explicit n ## _DictElement(const std::string &dictElement) \
|
||||
: VariableDictElement(#N, dictElement) { } \
|
||||
\
|
||||
void evaluate(Transaction *transaction, \
|
||||
@ -114,9 +114,9 @@ class KeyExclusion {
|
||||
// FIXME: use pre built regex.
|
||||
class KeyExclusionRegex : public KeyExclusion {
|
||||
public:
|
||||
explicit KeyExclusionRegex(Utils::Regex re)
|
||||
explicit KeyExclusionRegex(const Utils::Regex &re)
|
||||
: m_re(re.pattern) { }
|
||||
explicit KeyExclusionRegex(std::string re)
|
||||
explicit KeyExclusionRegex(const std::string &re)
|
||||
: m_re(re) { }
|
||||
|
||||
~KeyExclusionRegex() override { }
|
||||
@ -131,7 +131,7 @@ class KeyExclusionRegex : public KeyExclusion {
|
||||
|
||||
class KeyExclusionString : public KeyExclusion {
|
||||
public:
|
||||
KeyExclusionString(std::string &a)
|
||||
explicit KeyExclusionString(std::string &a)
|
||||
: m_key(utils::string::toupper(a)) { }
|
||||
|
||||
~KeyExclusionString() override { }
|
||||
@ -562,7 +562,7 @@ class Variable : public VariableMonkeyResolution {
|
||||
void addsKeyExclusion(Variable *v);
|
||||
|
||||
|
||||
bool operator==(const Variable& b) {
|
||||
bool operator==(const Variable& b) const {
|
||||
return m_collectionName == b.m_collectionName &&
|
||||
m_name == b.m_name &&
|
||||
*m_fullName == *b.m_fullName;
|
||||
@ -580,7 +580,7 @@ class Variable : public VariableMonkeyResolution {
|
||||
|
||||
class VariableDictElement : public Variable {
|
||||
public:
|
||||
VariableDictElement(std::string name, std::string dict_element)
|
||||
VariableDictElement(const std::string &name, const std::string &dict_element)
|
||||
: m_dictElement(dict_element), Variable(name + ":" + dict_element) { }
|
||||
|
||||
std::string m_dictElement;
|
||||
@ -589,14 +589,14 @@ class VariableDictElement : public Variable {
|
||||
|
||||
class VariableRegex : public Variable {
|
||||
public:
|
||||
VariableRegex(std::string name, std::string regex)
|
||||
VariableRegex(const std::string &name, const std::string ®ex)
|
||||
: m_r(regex),
|
||||
m_regex(regex),
|
||||
Variable(name + ":" + "regex(" + regex + ")") { }
|
||||
|
||||
Utils::Regex m_r;
|
||||
// FIXME: no need for that.
|
||||
std::string m_regex;
|
||||
Utils::Regex m_r;
|
||||
};
|
||||
|
||||
class Variables : public std::vector<Variable *> {
|
||||
@ -621,11 +621,12 @@ class Variables : public std::vector<Variable *> {
|
||||
class VariableModificatorExclusion : public Variable {
|
||||
public:
|
||||
explicit VariableModificatorExclusion(std::unique_ptr<Variable> var)
|
||||
: m_base(std::move(var)), Variable(var.get()) { }
|
||||
: Variable(var.get()),
|
||||
m_base(std::move(var)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
m_base->evaluate(t, rule, l);
|
||||
}
|
||||
|
||||
@ -643,7 +644,7 @@ class VariableModificatorCount : public Variable {
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::vector<const VariableValue *> reslIn;
|
||||
VariableValue *val = NULL;
|
||||
int count = 0;
|
||||
|
@ -55,7 +55,7 @@ class XML_NoDictElement : public Variable {
|
||||
|
||||
class XML : public Variable {
|
||||
public:
|
||||
explicit XML(std::string _name)
|
||||
explicit XML(const std::string &_name)
|
||||
: Variable(_name) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
|
Loading…
x
Reference in New Issue
Block a user