mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Code cosmetics
This commit is contained in:
parent
3c45a57130
commit
de79848285
@ -24,13 +24,15 @@ typedef struct Collection_t Collection;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
|
||||
namespace ModSecurity {
|
||||
|
||||
class Collection : public transaction::Variables {
|
||||
public:
|
||||
Collection(std::string name, std::string key)
|
||||
: m_name(name),
|
||||
m_key(key) { };
|
||||
m_key(key) { }
|
||||
|
||||
std::string m_name;
|
||||
clock_t m_createTime;
|
||||
|
@ -61,7 +61,6 @@ class Variables :
|
||||
std::vector<const transaction::Variable *> *l);
|
||||
void resolveRegularExpression(const std::string& var,
|
||||
std::vector<const transaction::Variable *> *l);
|
||||
|
||||
};
|
||||
|
||||
} // namespace transaction
|
||||
|
@ -30,7 +30,8 @@ namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
|
||||
class HtmlEntityDecodeInstantCache : public std::unordered_map<std::string, std::string> {
|
||||
class HtmlEntityDecodeInstantCache :
|
||||
public std::unordered_map<std::string, std::string> {
|
||||
public:
|
||||
static HtmlEntityDecodeInstantCache& getInstance() {
|
||||
static HtmlEntityDecodeInstantCache instance;
|
||||
@ -44,7 +45,7 @@ class HtmlEntityDecodeInstantCache : public std::unordered_map<std::string, std:
|
||||
}
|
||||
}
|
||||
private:
|
||||
HtmlEntityDecodeInstantCache() {};
|
||||
HtmlEntityDecodeInstantCache() {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,7 +29,8 @@ class Assay;
|
||||
namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
class LowerCaseInstantCache : public std::unordered_map<std::string, std::string> {
|
||||
class LowerCaseInstantCache :
|
||||
public std::unordered_map<std::string, std::string> {
|
||||
public:
|
||||
static LowerCaseInstantCache& getInstance() {
|
||||
static LowerCaseInstantCache instance;
|
||||
@ -43,7 +44,7 @@ class LowerCaseInstantCache : public std::unordered_map<std::string, std::string
|
||||
}
|
||||
}
|
||||
private:
|
||||
LowerCaseInstantCache() {};
|
||||
LowerCaseInstantCache() {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,7 +29,8 @@ class Assay;
|
||||
namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
class UrlDecodeInstantCache : public std::unordered_map<std::string, std::string> {
|
||||
class UrlDecodeInstantCache :
|
||||
public std::unordered_map<std::string, std::string> {
|
||||
public:
|
||||
static UrlDecodeInstantCache& getInstance() {
|
||||
static UrlDecodeInstantCache instance;
|
||||
@ -43,7 +44,7 @@ class UrlDecodeInstantCache : public std::unordered_map<std::string, std::string
|
||||
}
|
||||
}
|
||||
private:
|
||||
UrlDecodeInstantCache() {};
|
||||
UrlDecodeInstantCache() {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -132,9 +132,7 @@ void Collections::resolveSingleMatch(const std::string& var,
|
||||
|
||||
try {
|
||||
this->at(collection)->resolveSingleMatch(var, l);
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
void Collections::resolveMultiMatches(const std::string& var,
|
||||
@ -149,9 +147,7 @@ void Collections::resolveMultiMatches(const std::string& var,
|
||||
std::vector<const transaction::Variable *> *l) {
|
||||
try {
|
||||
this->at(collection)->resolveMultiMatches(var, l);
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
void Collections::resolveRegularExpression(const std::string& var,
|
||||
@ -166,9 +162,7 @@ void Collections::resolveRegularExpression(const std::string& var,
|
||||
|
||||
try {
|
||||
this->at(collection)->resolveRegularExpression(var, l);
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
} // namespace transaction
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define SRC_OPERATORS_DETECT_SQLI_H_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "operators/operator.h"
|
||||
|
||||
|
@ -488,7 +488,6 @@ bool Rule::evaluate(Assay *assay) {
|
||||
delete e.back();
|
||||
e.pop_back();
|
||||
}
|
||||
//delete e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -96,8 +96,7 @@ void Variables::resolveMultiMatches(const std::string& var,
|
||||
if (x.first.compare(0, keySize, var) != 0) {
|
||||
continue;
|
||||
}
|
||||
const transaction::Variable *v = new transaction::Variable(x.first, x.second);
|
||||
l->insert(l->begin(), v);
|
||||
l->insert(l->begin(), new transaction::Variable(x.first, x.second));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ Variable::Variable(std::string name)
|
||||
m_collectionName(""),
|
||||
m_isExclusion(false),
|
||||
m_isCount(false) {
|
||||
|
||||
if (m_name.at(0) == '\\') {
|
||||
m_type = RegularExpression;
|
||||
} else if (m_name.find(":") != std::string::npos) {
|
||||
@ -58,7 +57,6 @@ Variable::Variable(std::string name, VariableKind kind)
|
||||
m_kind(kind),
|
||||
m_isExclusion(false),
|
||||
m_isCount(false) {
|
||||
|
||||
if (m_name.at(0) == '\\') {
|
||||
m_type = RegularExpression;
|
||||
} else if (m_name.find(":") != std::string::npos) {
|
||||
@ -75,25 +73,32 @@ Variable::Variable(std::string name, VariableKind kind)
|
||||
|
||||
std::vector<const transaction::Variable *> *
|
||||
Variable::evaluate(Assay *assay) {
|
||||
std::vector<const transaction::Variable *> *l = new std::vector<const transaction::Variable *>();
|
||||
std::vector<const transaction::Variable *> *l = NULL;
|
||||
l = new std::vector<const transaction::Variable *>();
|
||||
evaluate(assay, l);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
void Variable::evaluateInternal(Assay *assay, std::vector<const transaction::Variable *> *l) {
|
||||
void Variable::evaluateInternal(Assay *assay,
|
||||
std::vector<const transaction::Variable *> *l) {
|
||||
if (m_collectionName.empty() == false) {
|
||||
if (m_kind == CollectionVarible && m_type == MultipleMatches) {
|
||||
assay->m_collections.resolveMultiMatches(m_name, m_collectionName, l);
|
||||
} if (m_kind == CollectionVarible && m_type == RegularExpression) {
|
||||
assay->m_collections.resolveRegularExpression(m_name, m_collectionName, l);
|
||||
assay->m_collections.resolveMultiMatches(m_name,
|
||||
m_collectionName, l);
|
||||
} else if (m_kind == CollectionVarible
|
||||
&& m_type == RegularExpression) {
|
||||
assay->m_collections.resolveRegularExpression(m_name,
|
||||
m_collectionName, l);
|
||||
} else {
|
||||
assay->m_collections.resolveSingleMatch(m_name, m_collectionName, l);
|
||||
assay->m_collections.resolveSingleMatch(m_name,
|
||||
m_collectionName, l);
|
||||
}
|
||||
} else {
|
||||
if (m_kind == CollectionVarible && m_type == MultipleMatches) {
|
||||
assay->m_collections.resolveMultiMatches(m_name, l);
|
||||
} if (m_kind == CollectionVarible && m_type == RegularExpression) {
|
||||
} else if (m_kind == CollectionVarible
|
||||
&& m_type == RegularExpression) {
|
||||
assay->m_collections.resolveRegularExpression(m_name, l);
|
||||
} else {
|
||||
assay->m_collections.resolveSingleMatch(m_name, l);
|
||||
@ -102,7 +107,8 @@ void Variable::evaluateInternal(Assay *assay, std::vector<const transaction::Var
|
||||
}
|
||||
|
||||
|
||||
void Variable::evaluate(Assay *assay, std::vector<const transaction::Variable *> *l) {
|
||||
void Variable::evaluate(Assay *assay,
|
||||
std::vector<const transaction::Variable *> *l) {
|
||||
evaluateInternal(assay, l);
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,10 @@ class Variable {
|
||||
static std::string to_s(std::vector<Variable *> *variables);
|
||||
|
||||
virtual std::vector<const transaction::Variable *> *evaluate(Assay *assay);
|
||||
virtual void evaluate(Assay *assay, std::vector<const transaction::Variable *> *l);
|
||||
virtual void evaluateInternal(Assay *assay, std::vector<const transaction::Variable *> *l);
|
||||
virtual void evaluate(Assay *assay,
|
||||
std::vector<const transaction::Variable *> *l);
|
||||
virtual void evaluateInternal(Assay *assay,
|
||||
std::vector<const transaction::Variable *> *l);
|
||||
|
||||
|
||||
std::string m_name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user