mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Fix assorted memory and static analysis errors
This commit is contained in:
parent
8d0583eda4
commit
e95efa05cc
@ -59,10 +59,10 @@ cppcheck:
|
||||
--enable=all \
|
||||
--inconclusive \
|
||||
--template="warning: {file},{line},{severity},{id},{message}" \
|
||||
-U YYSTYPE \
|
||||
-U YY_USER_INIT \
|
||||
--std=posix . 2> cppcheck.txt
|
||||
cat cppcheck.txt
|
||||
# -U YYSTYPE
|
||||
# -U YY_USER_INIT
|
||||
|
||||
check-static: cppcheck
|
||||
|
||||
|
@ -33,7 +33,7 @@ ModSecurity *modsec = NULL;
|
||||
|
||||
|
||||
void process_special_request (int j) {
|
||||
Transaction *transaction = NULL;
|
||||
Transaction *transaction;
|
||||
transaction = msc_new_transaction(modsec, rules, NULL);
|
||||
|
||||
msc_process_connection(transaction, "127.0.0.1", 12345, "127.0.0.1", 80);
|
||||
@ -61,7 +61,7 @@ void process_request (int j) {
|
||||
}
|
||||
struct timeval tv;
|
||||
|
||||
Transaction *transaction = NULL;
|
||||
Transaction *transaction;
|
||||
transaction = msc_new_transaction(modsec, rules, NULL);
|
||||
|
||||
msc_process_connection(transaction, "127.0.0.1", 12345, "127.0.0.1", 80);
|
||||
|
@ -27,9 +27,9 @@ int main (int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
const char *error = NULL;
|
||||
ModSecurity *modsec = NULL;
|
||||
ModSecurity *modsec;
|
||||
Transaction *transaction = NULL;
|
||||
Rules *rules = NULL;
|
||||
Rules *rules;
|
||||
|
||||
modsec = msc_init();
|
||||
|
||||
|
@ -25,9 +25,8 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "modsecurity/collection/variable.h"
|
||||
@ -66,8 +65,8 @@ struct MyHash{
|
||||
};
|
||||
|
||||
|
||||
class AnchoredSetVariable : public std::unordered_multimap<std::string, collection::Variable *,
|
||||
MyHash, MyEqual> {
|
||||
class AnchoredSetVariable : public std::unordered_multimap<std::string,
|
||||
collection::Variable *, MyHash, MyEqual> {
|
||||
public:
|
||||
AnchoredSetVariable(Transaction *t, std::string name);
|
||||
~AnchoredSetVariable();
|
||||
@ -76,6 +75,7 @@ class AnchoredSetVariable : public std::unordered_multimap<std::string, collecti
|
||||
|
||||
void set(const std::string &key, const std::string &value,
|
||||
size_t offset);
|
||||
void setCopy(std::string key, std::string value, size_t offset);
|
||||
|
||||
void resolve(std::vector<const collection::Variable *> *l);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "modsecurity/collection/variable.h"
|
||||
@ -64,5 +65,5 @@ class AnchoredVariable {
|
||||
#endif
|
||||
|
||||
|
||||
#endif // HEADERS_MODSECURITY_ANCHORED_SET_VARIABLE_H_
|
||||
#endif // HEADERS_MODSECURITY_ANCHORED_VARIABLE_H_
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
|
||||
@ -50,7 +51,8 @@ class Collection {
|
||||
|
||||
virtual void del(const std::string& key) = 0;
|
||||
|
||||
virtual std::unique_ptr<std::string> resolveFirst(const std::string& var) = 0;
|
||||
virtual std::unique_ptr<std::string> resolveFirst(
|
||||
const std::string& var) = 0;
|
||||
|
||||
virtual void resolveSingleMatch(const std::string& var,
|
||||
std::vector<const Variable *> *l) = 0;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "modsecurity/collection/collection.h"
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#ifndef HEADERS_MODSECURITY_RULE_H_
|
||||
@ -48,21 +49,20 @@ class Rule {
|
||||
std::vector<actions::Action *> *_actions,
|
||||
std::string fileName,
|
||||
int lineNumber);
|
||||
Rule(std::__cxx11::string marker);
|
||||
explicit Rule(std::__cxx11::string marker);
|
||||
~Rule();
|
||||
|
||||
bool evaluate(Transaction *transaction);
|
||||
bool evaluateActions(Transaction *transaction);
|
||||
std::vector<std::unique_ptr<collection::Variable>> getFinalVars(Transaction *trasn);
|
||||
std::vector<std::unique_ptr<collection::Variable>>
|
||||
getFinalVars(Transaction *trasn);
|
||||
void executeActionsAfterFullMatch(Transaction *trasn,
|
||||
bool containsDisruptive, RuleMessage *ruleMessage);
|
||||
std::list<
|
||||
std::pair<
|
||||
std::unique_ptr<std::string>,
|
||||
std::unique_ptr<std::string>
|
||||
>
|
||||
> executeSecDefaultActionTransofrmations(
|
||||
|
||||
std::list<std::pair<std::shared_ptr<std::string>,
|
||||
std::shared_ptr<std::string>>> executeDefaultTransformations(
|
||||
Transaction *trasn, const std::string &value, bool multiMatch);
|
||||
|
||||
bool executeOperatorAt(Transaction *trasn, std::string key,
|
||||
std::string value, RuleMessage *rm);
|
||||
void executeActionsIndependentOfChainedRuleResult(Transaction *trasn,
|
||||
@ -111,6 +111,7 @@ class Rule {
|
||||
bool m_secMarker;
|
||||
std::vector<Variables::Variable *> *m_variables;
|
||||
std::string m_ver;
|
||||
|
||||
private:
|
||||
bool m_unconditional;
|
||||
int m_referenceCount;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
@ -35,7 +35,7 @@ namespace transformations {
|
||||
std::string HexDecode::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
int size = 0;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
|
@ -36,7 +36,7 @@ namespace transformations {
|
||||
std::string HtmlEntityDecode::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
@ -98,7 +98,7 @@ int HtmlEntityDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
}
|
||||
if (j > k) { /* Do we have at least one digit? */
|
||||
/* Decode the entity. */
|
||||
char *x = NULL;
|
||||
char *x;
|
||||
x = reinterpret_cast<char *>(calloc(sizeof(char),
|
||||
((j - k) + 1)));
|
||||
memcpy(x, (const char *)&input[k], j - k);
|
||||
@ -124,7 +124,7 @@ int HtmlEntityDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
}
|
||||
if (j > k) { /* Do we have at least one digit? */
|
||||
/* Decode the entity. */
|
||||
char *x = NULL;
|
||||
char *x;
|
||||
x = reinterpret_cast<char *>(calloc(sizeof(char),
|
||||
((j - k) + 1)));
|
||||
memcpy(x, (const char *)&input[k], j - k);
|
||||
@ -150,7 +150,7 @@ int HtmlEntityDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
j++;
|
||||
}
|
||||
if (j > k) { /* Do we have at least one digit? */
|
||||
char *x = NULL;
|
||||
char *x;
|
||||
x = reinterpret_cast<char *>(calloc(sizeof(char),
|
||||
((j - k) + 1)));
|
||||
memcpy(x, (const char *)&input[k], j - k);
|
||||
|
@ -37,7 +37,7 @@ namespace transformations {
|
||||
std::string JsDecode::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
|
@ -35,7 +35,7 @@ namespace transformations {
|
||||
std::string ParityEven7bit::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
|
@ -35,7 +35,7 @@ namespace transformations {
|
||||
std::string ParityOdd7bit::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
|
@ -35,7 +35,7 @@ namespace transformations {
|
||||
std::string ParityZero7bit::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
|
@ -35,7 +35,7 @@ namespace transformations {
|
||||
std::string RemoveComments::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
|
@ -44,7 +44,7 @@ namespace transformations {
|
||||
std::string SqlHexDecode::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
int size = 0;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
|
@ -38,7 +38,7 @@ namespace transformations {
|
||||
std::string UrlDecodeUni::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
|
||||
input = reinterpret_cast<unsigned char *>
|
||||
(malloc(sizeof(char) * value.length()+1));
|
||||
|
@ -36,7 +36,7 @@ namespace transformations {
|
||||
std::string Utf8ToUnicode::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
std::string ret;
|
||||
unsigned char *input = NULL;
|
||||
unsigned char *input;
|
||||
int changed = 0;
|
||||
char *out;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "modsecurity/collection/variable.h"
|
||||
@ -155,7 +156,8 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<std::string> InMemoryPerProcess::resolveFirst(const std::string& var) {
|
||||
std::unique_ptr<std::string> InMemoryPerProcess::resolveFirst(
|
||||
const std::string& var) {
|
||||
auto range = equal_range(var);
|
||||
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "modsecurity/collection/variable.h"
|
||||
#include "src/utils/regex.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#ifdef WITH_LMDB
|
||||
|
@ -145,8 +145,8 @@ std::unique_ptr<std::string> Collections::resolveFirst(const std::string& var) {
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<std::string> Collections::resolveFirst(const std::string& collectionName,
|
||||
const std::string& var) {
|
||||
std::unique_ptr<std::string> Collections::resolveFirst(
|
||||
const std::string& collectionName, const std::string& var) {
|
||||
if (utils::string::tolower(collectionName) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
return m_ip_collection->resolveFirst(
|
||||
|
@ -13,6 +13,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/macro_expansion.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/collection/variable.h"
|
||||
|
@ -843,7 +843,7 @@ namespace yy {
|
||||
|
||||
|
||||
// User initialization code.
|
||||
#line 338 "/home/zimmerle/core/ModSecurity/src/parser/seclang-parser.yy" // lalr1.cc:741
|
||||
#line 338 "/home/zimmerle/core-trustwave/ModSecurity/src/parser/seclang-parser.yy" // lalr1.cc:741
|
||||
{
|
||||
// Initialize the initial location.
|
||||
yyla.location.begin.filename = yyla.location.end.filename = &driver.file;
|
||||
|
@ -343,8 +343,6 @@ int Multipart::parse_content_disposition(const char *c_d_value) {
|
||||
validate_quotes(value.c_str());
|
||||
|
||||
m_transaction->m_variableMultiPartName.set(value, value, 0);
|
||||
//m_transaction->m_collections.storeOrUpdateFirst("MULTIPART_NAME",
|
||||
// value);
|
||||
|
||||
if (!m_mpp->m_name.empty()) {
|
||||
debug(4, "Multipart: Warning: Duplicate Content-Disposition " \
|
||||
|
73
src/rule.cc
73
src/rule.cc
@ -206,20 +206,24 @@ void Rule::cleanMatchedVars(Transaction *trasn) {
|
||||
|
||||
void Rule::updateRulesVariable(Transaction *trasn) {
|
||||
if (m_ruleId != 0) {
|
||||
trasn->m_variableRule.set("id", std::to_string(m_ruleId), 0);
|
||||
trasn->m_variableRule.set("id",
|
||||
std::to_string(m_ruleId), 0);
|
||||
}
|
||||
if (m_rev.empty() == false) {
|
||||
trasn->m_variableRule.set("rev", m_rev, 0);
|
||||
trasn->m_variableRule.set("rev",
|
||||
m_rev, 0);
|
||||
}
|
||||
if (getActionsByName("msg").size() > 0) {
|
||||
actions::Msg *msg = dynamic_cast<actions::Msg*>(
|
||||
getActionsByName("msg")[0]);
|
||||
trasn->m_variableRule.set("msg", msg->data(trasn), 0);
|
||||
trasn->m_variableRule.set("msg",
|
||||
msg->data(trasn), 0);
|
||||
}
|
||||
if (getActionsByName("logdata").size() > 0) {
|
||||
actions::LogData *data = dynamic_cast<actions::LogData*>(
|
||||
getActionsByName("logdata")[0]);
|
||||
trasn->m_variableRule.set("logdata", data->data(trasn), 0);
|
||||
trasn->m_variableRule.set("logdata",
|
||||
data->data(trasn), 0);
|
||||
}
|
||||
if (getActionsByName("severity").size() > 0) {
|
||||
actions::Severity *data = dynamic_cast<actions::Severity*>(
|
||||
@ -295,34 +299,33 @@ bool Rule::executeOperatorAt(Transaction *trasn, std::string key,
|
||||
return ret;
|
||||
}
|
||||
|
||||
// FIXME: this should be a list instead of a vector, keeping the but
|
||||
// of v2 alive.
|
||||
std::list<std::pair<std::unique_ptr<std::string>,
|
||||
std::unique_ptr<std::string>>>
|
||||
Rule::executeSecDefaultActionTransofrmations(
|
||||
|
||||
std::list<std::pair<std::shared_ptr<std::string>,
|
||||
std::shared_ptr<std::string>>>
|
||||
Rule::executeDefaultTransformations(
|
||||
|
||||
Transaction *trasn, const std::string &in, bool multiMatch) {
|
||||
int none = 0;
|
||||
int transformations = 0;
|
||||
|
||||
std::list<std::pair<std::unique_ptr<std::string>,
|
||||
std::unique_ptr<std::string>>> ret;
|
||||
std::list<std::pair<std::shared_ptr<std::string>,
|
||||
std::shared_ptr<std::string>>> ret;
|
||||
|
||||
|
||||
std::unique_ptr<std::string> value =
|
||||
std::unique_ptr<std::string>(new std::string(in));
|
||||
std::unique_ptr<std::string> newValue;
|
||||
std::shared_ptr<std::string> value =
|
||||
std::shared_ptr<std::string>(new std::string(in));
|
||||
std::shared_ptr<std::string> newValue;
|
||||
|
||||
std::unique_ptr<std::string> trans =
|
||||
std::unique_ptr<std::string>(new std::string());
|
||||
std::shared_ptr<std::string> trans =
|
||||
std::shared_ptr<std::string>(new std::string());
|
||||
|
||||
if (multiMatch == true) {
|
||||
ret.push_back(std::make_pair(
|
||||
std::move(value),
|
||||
std::move(trans)));
|
||||
std::shared_ptr<std::string>(value),
|
||||
std::shared_ptr<std::string>(trans)));
|
||||
ret.push_back(std::make_pair(
|
||||
std::move(value),
|
||||
std::move(trans)));
|
||||
std::shared_ptr<std::string>(value),
|
||||
std::shared_ptr<std::string>(trans)));
|
||||
}
|
||||
|
||||
for (Action *a : this->m_actionsRuntimePre) {
|
||||
@ -344,11 +347,11 @@ std::list<std::pair<std::unique_ptr<std::string>,
|
||||
if (multiMatch == true) {
|
||||
if (*newValue != *value) {
|
||||
ret.push_back(std::make_pair(
|
||||
std::move(newValue),
|
||||
std::move(trans)));
|
||||
newValue,
|
||||
trans));
|
||||
}
|
||||
}
|
||||
value = std::move(newValue);
|
||||
value = std::shared_ptr<std::string>(newValue);
|
||||
if (trans->empty()) {
|
||||
trans->append(a->m_name);
|
||||
} else {
|
||||
@ -364,22 +367,21 @@ std::list<std::pair<std::unique_ptr<std::string>,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Action *a : this->m_actionsRuntimePre) {
|
||||
if (none == 0) {
|
||||
newValue = std::unique_ptr<std::string>(
|
||||
newValue = std::shared_ptr<std::string>(
|
||||
new std::string(a->evaluate(*value, trasn)));
|
||||
|
||||
if (multiMatch == true) {
|
||||
if (*value != *newValue) {
|
||||
ret.push_back(std::make_pair(
|
||||
std::move(newValue),
|
||||
std::move(trans)));
|
||||
value = std::move(newValue);
|
||||
newValue,
|
||||
trans));
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
value = std::move(newValue);
|
||||
value = newValue;
|
||||
trasn->debug(9, " T (" + \
|
||||
std::to_string(transformations) + ") " + \
|
||||
a->m_name + ": \"" + \
|
||||
@ -397,15 +399,15 @@ std::list<std::pair<std::unique_ptr<std::string>,
|
||||
}
|
||||
if (multiMatch == true) {
|
||||
// v2 checks the last entry twice. Don't know why.
|
||||
ret.push_back(std::move(ret.back()));
|
||||
ret.push_back(ret.back());
|
||||
|
||||
trasn->debug(9, "multiMatch is enabled. " \
|
||||
+ std::to_string(ret.size()) + \
|
||||
" values to be tested.");
|
||||
} else {
|
||||
ret.push_back(std::make_pair(
|
||||
std::move(value),
|
||||
std::move(trans)));
|
||||
std::shared_ptr<std::string>(value),
|
||||
std::shared_ptr<std::string>(trans)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -425,7 +427,6 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
|
||||
variable->evaluateInternal(trasn, this, &z);
|
||||
for (auto &y : z) {
|
||||
exclusions.push_back(y->m_key);
|
||||
//delete y;
|
||||
}
|
||||
exclusions.push_back(&variable->m_name);
|
||||
}
|
||||
@ -628,12 +629,12 @@ bool Rule::evaluate(Transaction *trasn) {
|
||||
const std::string value = *(v->m_value);
|
||||
const std::string key = *(v->m_key);
|
||||
|
||||
std::list<std::pair<std::unique_ptr<std::string>,
|
||||
std::unique_ptr<std::string>>> values;
|
||||
std::list<std::pair<std::shared_ptr<std::string>,
|
||||
std::shared_ptr<std::string>>> values;
|
||||
|
||||
bool multiMatch = getActionsByName("multimatch").size() > 0;
|
||||
|
||||
values = executeSecDefaultActionTransofrmations(trasn, value,
|
||||
values = executeDefaultTransformations(trasn, value,
|
||||
multiMatch);
|
||||
for (const auto &valueTemp : values) {
|
||||
bool ret;
|
||||
|
@ -97,8 +97,10 @@ std::string const UniqueId::machineName() {
|
||||
|
||||
return std::string(machine_name);
|
||||
|
||||
#if defined(HAVE_SYS_UTSNAME_H) || defined(WIN32)
|
||||
failed:
|
||||
return std::string("");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string const UniqueId::ethernetMacAddress() {
|
||||
@ -221,8 +223,10 @@ std::string const UniqueId::ethernetMacAddress() {
|
||||
|
||||
end:
|
||||
return std::string(reinterpret_cast<const char *>(mac));
|
||||
#if defined(__linux__) || defined(__gnu_linux__) || defined(DARWIN) || defined(WIN32)
|
||||
failed:
|
||||
return std::string("");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
||||
|
||||
char *parse_pm_content(const char *op_parm, unsigned short int op_len, const char **error_msg) {
|
||||
char *parm = NULL;
|
||||
char *content = NULL;
|
||||
char *content;
|
||||
unsigned short int offset = 0;
|
||||
// char converted = 0;
|
||||
int i, x;
|
||||
|
@ -29,7 +29,7 @@ namespace Utils {
|
||||
|
||||
std::string Base64::encode(const std::string& data) {
|
||||
size_t encoded_len = 0;
|
||||
unsigned char *d = NULL;
|
||||
unsigned char *d;
|
||||
std::string ret;
|
||||
|
||||
mbedtls_base64_encode(NULL, 0, &encoded_len,
|
||||
@ -64,7 +64,7 @@ std::string Base64::decode(const std::string& data, bool forgiven) {
|
||||
|
||||
std::string Base64::decode(const std::string& data) {
|
||||
size_t decoded_len = 0;
|
||||
unsigned char *d = NULL;
|
||||
unsigned char *d;
|
||||
std::string ret;
|
||||
size_t len = strlen(data.c_str());
|
||||
|
||||
@ -90,7 +90,7 @@ std::string Base64::decode(const std::string& data) {
|
||||
|
||||
std::string Base64::decode_forgiven(const std::string& data) {
|
||||
size_t decoded_len = 0;
|
||||
unsigned char *d = NULL;
|
||||
unsigned char *d;
|
||||
std::string ret;
|
||||
|
||||
decode_forgiven_engine(NULL, 0, &decoded_len,
|
||||
|
@ -24,7 +24,7 @@
|
||||
extern "C" {
|
||||
|
||||
CPTTree *CPTCreateRadixTree() {
|
||||
CPTTree *tree = NULL;
|
||||
CPTTree *tree;
|
||||
|
||||
tree = reinterpret_cast<CPTTree *>(malloc(sizeof(CPTTree)));
|
||||
|
||||
@ -60,7 +60,7 @@ void ConvertIPNetmask(unsigned char *buffer, unsigned char netmask, unsigned int
|
||||
}
|
||||
|
||||
TreeNode *CPTCreateNode() {
|
||||
TreeNode *node = NULL;
|
||||
TreeNode *node;
|
||||
|
||||
node = reinterpret_cast<TreeNode *>(malloc(sizeof(TreeNode)));
|
||||
|
||||
@ -247,7 +247,7 @@ TreeNode *SetParentNode(TreeNode *node, TreeNode *new_node, CPTTree *tree) {
|
||||
int InsertNetmask(TreeNode *node, TreeNode *parent, TreeNode *new_node,
|
||||
CPTTree *tree, unsigned char netmask, unsigned char bitlen) {
|
||||
if (netmask != NETMASK_256-1 && netmask != NETMASK_128) {
|
||||
if ((netmask != NETMASK_32 || (netmask == NETMASK_32 && bitlen != NETMASK_32))) {
|
||||
if (netmask != NETMASK_32 || bitlen != NETMASK_32) {
|
||||
int i;
|
||||
node = new_node;
|
||||
parent = new_node->parent;
|
||||
@ -383,7 +383,7 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
|
||||
if (test_bit == bitlen && node->bit == bitlen) {
|
||||
if (node->prefix != NULL) {
|
||||
int found = 0;
|
||||
CPTData *prefix_data = NULL;
|
||||
CPTData *prefix_data;
|
||||
|
||||
prefix_data = node->prefix->prefix_data;
|
||||
|
||||
@ -966,7 +966,7 @@ int add_ip_from_param(
|
||||
{
|
||||
char *param_copy = strdup(param);
|
||||
char *saved = NULL;
|
||||
char *str = NULL;
|
||||
char *str;
|
||||
TreeNode *tnode = NULL;
|
||||
|
||||
str = strtok_r(param_copy, ",", &saved);
|
||||
|
@ -59,7 +59,7 @@ double cpu_seconds(void) {
|
||||
|
||||
std::string find_resource(const std::string& resource,
|
||||
const std::string& config) {
|
||||
std::ifstream *iss = NULL;
|
||||
std::ifstream *iss;
|
||||
|
||||
// Trying absolute or relative to the current dir.
|
||||
iss = new std::ifstream(resource, std::ios::in);
|
||||
|
@ -31,13 +31,13 @@ namespace Variables {
|
||||
|
||||
class Args_DictElement : public Variable {
|
||||
public:
|
||||
Args_DictElement(std::string dictElement)
|
||||
explicit Args_DictElement(std::string dictElement)
|
||||
: Variable("ARGS" + std::string(":") + std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableArgs.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class Args_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableArgs.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -60,7 +60,7 @@ class Args_NoDictElement : public Variable {
|
||||
|
||||
class Args_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Args_DictElementRegexp(std::string dictElement)
|
||||
explicit Args_DictElementRegexp(std::string dictElement)
|
||||
: Variable("ARGS:regex(" + dictElement + ")"),
|
||||
m_r(dictElement) {
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ namespace Variables {
|
||||
|
||||
class ArgsGet_DictElement : public Variable {
|
||||
public:
|
||||
ArgsGet_DictElement(std::string dictElement)
|
||||
explicit ArgsGet_DictElement(std::string dictElement)
|
||||
: Variable("ARGS_GET" + std::string(":") + std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableArgsGet.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class ArgsGet_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableArgsGet.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -60,7 +60,7 @@ class ArgsGet_NoDictElement : public Variable {
|
||||
|
||||
class ArgsGet_DictElementRegexp : public Variable {
|
||||
public:
|
||||
ArgsGet_DictElementRegexp(std::string dictElement)
|
||||
explicit ArgsGet_DictElementRegexp(std::string dictElement)
|
||||
: Variable("ARGS_GET"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,13 +31,13 @@ namespace Variables {
|
||||
|
||||
class ArgsPost_DictElement : public Variable {
|
||||
public:
|
||||
ArgsPost_DictElement(std::string dictElement)
|
||||
explicit ArgsPost_DictElement(std::string dictElement)
|
||||
: Variable("ARGS_POST" + std::string(":") + std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableArgsPost.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class ArgsPost_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableArgsPost.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -60,7 +60,7 @@ class ArgsPost_NoDictElement : public Variable {
|
||||
|
||||
class ArgsPost_DictElementRegexp : public Variable {
|
||||
public:
|
||||
ArgsPost_DictElementRegexp(std::string dictElement)
|
||||
explicit ArgsPost_DictElementRegexp(std::string dictElement)
|
||||
: Variable("ARGS_POST"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class Files_DictElement : public Variable {
|
||||
public:
|
||||
Files_DictElement(std::string dictElement)
|
||||
explicit Files_DictElement(std::string dictElement)
|
||||
: Variable("FILES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFiles.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class Files_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFiles.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class Files_NoDictElement : public Variable {
|
||||
|
||||
class Files_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Files_DictElementRegexp(std::string dictElement)
|
||||
explicit Files_DictElementRegexp(std::string dictElement)
|
||||
: Variable("FILES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class FilesNames_DictElement : public Variable {
|
||||
public:
|
||||
FilesNames_DictElement(std::string dictElement)
|
||||
explicit FilesNames_DictElement(std::string dictElement)
|
||||
: Variable("FILES_NAMES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesNames.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class FilesNames_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesNames.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class FilesNames_NoDictElement : public Variable {
|
||||
|
||||
class FilesNames_DictElementRegexp : public Variable {
|
||||
public:
|
||||
FilesNames_DictElementRegexp(std::string dictElement)
|
||||
explicit FilesNames_DictElementRegexp(std::string dictElement)
|
||||
: Variable("FILES_NAMES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class FilesSizes_DictElement : public Variable {
|
||||
public:
|
||||
FilesSizes_DictElement(std::string dictElement)
|
||||
explicit FilesSizes_DictElement(std::string dictElement)
|
||||
: Variable("FILES_SIZES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesSizes.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class FilesSizes_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesSizes.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class FilesSizes_NoDictElement : public Variable {
|
||||
|
||||
class FilesSizes_DictElementRegexp : public Variable {
|
||||
public:
|
||||
FilesSizes_DictElementRegexp(std::string dictElement)
|
||||
explicit FilesSizes_DictElementRegexp(std::string dictElement)
|
||||
: Variable("FILES_SIZES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class FilesTmpContent_DictElement : public Variable {
|
||||
public:
|
||||
FilesTmpContent_DictElement(std::string dictElement)
|
||||
explicit FilesTmpContent_DictElement(std::string dictElement)
|
||||
: Variable("FILES_TMP_CONTENT" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesTmpContent.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class FilesTmpContent_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesTmpContent.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class FilesTmpContent_NoDictElement : public Variable {
|
||||
|
||||
class FilesTmpContent_DictElementRegexp : public Variable {
|
||||
public:
|
||||
FilesTmpContent_DictElementRegexp(std::string dictElement)
|
||||
explicit FilesTmpContent_DictElementRegexp(std::string dictElement)
|
||||
: Variable("FILES_TMP_CONTENT"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -30,14 +30,14 @@ class Transaction;
|
||||
namespace Variables {
|
||||
class FilesTmpNames_DictElement : public Variable {
|
||||
public:
|
||||
FilesTmpNames_DictElement(std::string dictElement)
|
||||
explicit FilesTmpNames_DictElement(std::string dictElement)
|
||||
: Variable("FILES_TMPNAMES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesTmpNames.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class FilesTmpNames_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableFilesTmpNames.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -60,7 +60,7 @@ class FilesTmpNames_NoDictElement : public Variable {
|
||||
|
||||
class FilesTmpNames_DictElementRegexp : public Variable {
|
||||
public:
|
||||
FilesTmpNames_DictElementRegexp(std::string dictElement)
|
||||
explicit FilesTmpNames_DictElementRegexp(std::string dictElement)
|
||||
: Variable("FILES_TMPNAMES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class Geo_DictElement : public Variable {
|
||||
public:
|
||||
Geo_DictElement(std::string dictElement)
|
||||
explicit Geo_DictElement(std::string dictElement)
|
||||
: Variable("GEO" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableGeo.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class Geo_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableGeo.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class Geo_NoDictElement : public Variable {
|
||||
|
||||
class Geo_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Geo_DictElementRegexp(std::string dictElement)
|
||||
explicit Geo_DictElementRegexp(std::string dictElement)
|
||||
: Variable("GEO"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -39,7 +39,8 @@ class Global_DictElement : public Variable {
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_collections.resolveMultiMatches(m_dictElement, "GLOBAL", l);
|
||||
transaction->m_collections.resolveMultiMatches(m_dictElement,
|
||||
"GLOBAL", l);
|
||||
}
|
||||
|
||||
std::string m_dictElement;
|
||||
@ -48,7 +49,7 @@ class Global_DictElement : public Variable {
|
||||
|
||||
class Global_NoDictElement : public Variable {
|
||||
public:
|
||||
explicit Global_NoDictElement()
|
||||
Global_NoDictElement()
|
||||
: Variable("GLOBAL") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
@ -61,7 +62,7 @@ class Global_NoDictElement : public Variable {
|
||||
|
||||
class Global_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Global_DictElementRegexp(std::string dictElement)
|
||||
explicit Global_DictElementRegexp(std::string dictElement)
|
||||
: Variable("GLOBAL"),
|
||||
m_r(dictElement),
|
||||
m_dictElement("GLOBAL:" + dictElement) { }
|
||||
|
@ -48,7 +48,7 @@ class Ip_DictElement : public Variable {
|
||||
|
||||
class Ip_NoDictElement : public Variable {
|
||||
public:
|
||||
explicit Ip_NoDictElement()
|
||||
Ip_NoDictElement()
|
||||
: Variable("IP") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
@ -61,7 +61,7 @@ class Ip_NoDictElement : public Variable {
|
||||
|
||||
class Ip_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Ip_DictElementRegexp(std::string dictElement)
|
||||
explicit Ip_DictElementRegexp(std::string dictElement)
|
||||
: Variable("IP"),
|
||||
m_r(dictElement),
|
||||
m_dictElement("IP:" + dictElement) { }
|
||||
|
@ -36,7 +36,7 @@ class MatchedVarName : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMatchedVarName.evaluate(l);
|
||||
}
|
||||
};
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class MatchedVars_DictElement : public Variable {
|
||||
public:
|
||||
MatchedVars_DictElement(std::string dictElement)
|
||||
explicit MatchedVars_DictElement(std::string dictElement)
|
||||
: Variable("MATCHED_VARS" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMatchedVars.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class MatchedVars_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMatchedVars.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class MatchedVars_NoDictElement : public Variable {
|
||||
|
||||
class MatchedVars_DictElementRegexp : public Variable {
|
||||
public:
|
||||
MatchedVars_DictElementRegexp(std::string dictElement)
|
||||
explicit MatchedVars_DictElementRegexp(std::string dictElement)
|
||||
: Variable("MATCHED_VARS"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class MatchedVarsNames_DictElement : public Variable {
|
||||
public:
|
||||
MatchedVarsNames_DictElement(std::string dictElement)
|
||||
explicit MatchedVarsNames_DictElement(std::string dictElement)
|
||||
: Variable("MATCHED_VARS_NAMES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMatchedVarsNames.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class MatchedVarsNames_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMatchedVarsNames.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,13 +61,13 @@ class MatchedVarsNames_NoDictElement : public Variable {
|
||||
|
||||
class MatchedVarsNames_DictElementRegexp : public Variable {
|
||||
public:
|
||||
MatchedVarsNames_DictElementRegexp(std::string dictElement)
|
||||
explicit MatchedVarsNames_DictElementRegexp(std::string dictElement)
|
||||
: Variable("MATCHED_VARS_NAMES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMatchedVarsNames.resolveRegularExpression(
|
||||
&m_r, l);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#ifndef SRC_VARIABLES_MULTIPART_FILENAME_H_
|
||||
#define SRC_VARIABLES_MULTIPART_FILENAME_H_
|
||||
#ifndef SRC_VARIABLES_MULTIPART_FILE_NAME_H_
|
||||
#define SRC_VARIABLES_MULTIPART_FILE_NAME_H_
|
||||
|
||||
#include "src/variables/variable.h"
|
||||
|
||||
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class MultiPartFileName_DictElement : public Variable {
|
||||
public:
|
||||
MultiPartFileName_DictElement(std::string dictElement)
|
||||
explicit MultiPartFileName_DictElement(std::string dictElement)
|
||||
: Variable("MULTIPART_FILENAME" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMultiPartFileName.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class MultiPartFileName_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMultiPartFileName.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class MultiPartFileName_NoDictElement : public Variable {
|
||||
|
||||
class MultiPartFileName_DictElementRegexp : public Variable {
|
||||
public:
|
||||
MultiPartFileName_DictElementRegexp(std::string dictElement)
|
||||
explicit MultiPartFileName_DictElementRegexp(std::string dictElement)
|
||||
: Variable("MULTIPART_FILENAME"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
@ -79,5 +79,5 @@ class MultiPartFileName_DictElementRegexp : public Variable {
|
||||
} // namespace Variables
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_VARIABLES_MULTIPART_FILENAME_H_
|
||||
#endif // SRC_VARIABLES_MULTIPART_FILE_NAME_H_
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class MultiPartName_DictElement : public Variable {
|
||||
public:
|
||||
MultiPartName_DictElement(std::string dictElement)
|
||||
explicit MultiPartName_DictElement(std::string dictElement)
|
||||
: Variable("MULTIPART_NAME" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMultiPartName.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class MultiPartName_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableMultiPartName.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class MultiPartName_NoDictElement : public Variable {
|
||||
|
||||
class MultiPartName_DictElementRegexp : public Variable {
|
||||
public:
|
||||
MultiPartName_DictElementRegexp(std::string dictElement)
|
||||
explicit MultiPartName_DictElementRegexp(std::string dictElement)
|
||||
: Variable("MULTIPART_NAME"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
@ -79,5 +79,5 @@ class MultiPartName_DictElementRegexp : public Variable {
|
||||
} // namespace Variables
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_VARIABLES_MULTIPART_FILENAME_H_
|
||||
#endif // SRC_VARIABLES_MULTIPART_NAME_H_
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils/base64.h"
|
||||
@ -41,8 +42,8 @@ void RemoteUser::evaluate(Transaction *transaction,
|
||||
size_t pos;
|
||||
std::string base64;
|
||||
|
||||
std::unique_ptr<std::string> header = std::move(transaction->m_variableRequestHeaders.resolveFirst(
|
||||
"Authorization"));
|
||||
std::unique_ptr<std::string> header = std::move(
|
||||
transaction->m_variableRequestHeaders.resolveFirst("Authorization"));
|
||||
|
||||
if (header == NULL) {
|
||||
return;
|
||||
@ -62,7 +63,6 @@ void RemoteUser::evaluate(Transaction *transaction,
|
||||
|
||||
l->push_back(new collection::Variable(&m_retName,
|
||||
&transaction->m_variableRemoteUser));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class RequestCookies_DictElement : public Variable {
|
||||
public:
|
||||
RequestCookies_DictElement(std::string dictElement)
|
||||
explicit RequestCookies_DictElement(std::string dictElement)
|
||||
: Variable("REQUEST_COOKIES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestCookies.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class RequestCookies_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestCookies.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,13 +61,13 @@ class RequestCookies_NoDictElement : public Variable {
|
||||
|
||||
class RequestCookies_DictElementRegexp : public Variable {
|
||||
public:
|
||||
RequestCookies_DictElementRegexp(std::string dictElement)
|
||||
explicit RequestCookies_DictElementRegexp(std::string dictElement)
|
||||
: Variable("REQUEST_COOKIES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestCookies.resolveRegularExpression(
|
||||
&m_r, l);
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class RequestCookiesNames_DictElement : public Variable {
|
||||
public:
|
||||
RequestCookiesNames_DictElement(std::string dictElement)
|
||||
explicit RequestCookiesNames_DictElement(std::string dictElement)
|
||||
: Variable("REQUEST_COOKIES_NAMES" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestCookiesNames.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class RequestCookiesNames_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestCookiesNames.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class RequestCookiesNames_NoDictElement : public Variable {
|
||||
|
||||
class RequestCookiesNames_DictElementRegexp : public Variable {
|
||||
public:
|
||||
RequestCookiesNames_DictElementRegexp(std::string dictElement)
|
||||
explicit RequestCookiesNames_DictElementRegexp(std::string dictElement)
|
||||
: Variable("REQUEST_COOKIES_NAMES"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class RequestHeaders_DictElement : public Variable {
|
||||
public:
|
||||
RequestHeaders_DictElement(std::string dictElement)
|
||||
explicit RequestHeaders_DictElement(std::string dictElement)
|
||||
: Variable("REQUEST_HEADERS" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestHeaders.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class RequestHeaders_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRequestHeaders.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class RequestHeaders_NoDictElement : public Variable {
|
||||
|
||||
class RequestHeaders_DictElementRegexp : public Variable {
|
||||
public:
|
||||
RequestHeaders_DictElementRegexp(std::string dictElement)
|
||||
explicit RequestHeaders_DictElementRegexp(std::string dictElement)
|
||||
: Variable("REQUEST_HEADERS"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace Variables {
|
||||
|
||||
class ResponseHeaders_DictElement : public Variable {
|
||||
public:
|
||||
ResponseHeaders_DictElement(std::string dictElement)
|
||||
explicit ResponseHeaders_DictElement(std::string dictElement)
|
||||
: Variable("RESPONSE_HEADERS" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableResponseHeaders.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class ResponseHeaders_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableResponseHeaders.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -61,7 +61,7 @@ class ResponseHeaders_NoDictElement : public Variable {
|
||||
|
||||
class ResponseHeaders_DictElementRegexp : public Variable {
|
||||
public:
|
||||
ResponseHeaders_DictElementRegexp(std::string dictElement)
|
||||
explicit ResponseHeaders_DictElementRegexp(std::string dictElement)
|
||||
: Variable("RESPONSE_HEADERS"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -29,14 +29,14 @@ namespace Variables {
|
||||
|
||||
class Rule_DictElement : public Variable {
|
||||
public:
|
||||
Rule_DictElement(std::string dictElement)
|
||||
explicit Rule_DictElement(std::string dictElement)
|
||||
: Variable("RULE" + std::string(":") +
|
||||
std::string(dictElement)),
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRule.resolve(m_dictElement, l);
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ class Rule_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_variableRule.resolve(l);
|
||||
}
|
||||
};
|
||||
@ -59,7 +59,7 @@ class Rule_NoDictElement : public Variable {
|
||||
|
||||
class Rule_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Rule_DictElementRegexp(std::string dictElement)
|
||||
explicit Rule_DictElementRegexp(std::string dictElement)
|
||||
: Variable("RULE"),
|
||||
m_r(dictElement) { }
|
||||
|
||||
|
@ -39,7 +39,8 @@ class Session_DictElement : public Variable {
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
transaction->m_collections.resolveMultiMatches(m_dictElement, "SESSION", l);
|
||||
transaction->m_collections.resolveMultiMatches(m_dictElement,
|
||||
"SESSION", l);
|
||||
}
|
||||
|
||||
std::string m_dictElement;
|
||||
@ -48,7 +49,7 @@ class Session_DictElement : public Variable {
|
||||
|
||||
class Session_NoDictElement : public Variable {
|
||||
public:
|
||||
explicit Session_NoDictElement()
|
||||
Session_NoDictElement()
|
||||
: Variable("SESSION") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
@ -61,7 +62,7 @@ class Session_NoDictElement : public Variable {
|
||||
|
||||
class Session_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Session_DictElementRegexp(std::string dictElement)
|
||||
explicit Session_DictElementRegexp(std::string dictElement)
|
||||
: Variable("SESSION"),
|
||||
m_r(dictElement),
|
||||
m_dictElement("SESSION:" + dictElement) { }
|
||||
|
@ -45,8 +45,6 @@ void TimeWDay::evaluate(Transaction *transaction,
|
||||
|
||||
localtime_r(&timer, &timeinfo);
|
||||
strftime(tstr, 200, "%u", &timeinfo);
|
||||
int a = atoi(tstr);
|
||||
a--;
|
||||
|
||||
transaction->m_variableTimeWDay.assign(tstr);
|
||||
|
||||
|
@ -48,7 +48,7 @@ class Tx_DictElement : public Variable {
|
||||
|
||||
class Tx_NoDictElement : public Variable {
|
||||
public:
|
||||
explicit Tx_NoDictElement()
|
||||
Tx_NoDictElement()
|
||||
: Variable("TX") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
@ -61,7 +61,7 @@ class Tx_NoDictElement : public Variable {
|
||||
|
||||
class Tx_DictElementRegexp : public Variable {
|
||||
public:
|
||||
Tx_DictElementRegexp(std::string dictElement)
|
||||
explicit Tx_DictElementRegexp(std::string dictElement)
|
||||
: Variable("TX"),
|
||||
m_r(dictElement),
|
||||
m_dictElement("TX:" + dictElement) { }
|
||||
|
@ -122,7 +122,7 @@ Variable::Variable(std::string name, VariableKind kind)
|
||||
|
||||
std::vector<const collection::Variable *> *
|
||||
Variable::evaluate(Transaction *transaction) {
|
||||
std::vector<const collection::Variable *> *l = NULL;
|
||||
std::vector<const collection::Variable *> *l;
|
||||
l = new std::vector<const collection::Variable *>();
|
||||
evaluate(transaction, NULL, l);
|
||||
|
||||
@ -170,7 +170,8 @@ std::string Variable::to_s(
|
||||
std::string except("");
|
||||
for (int i = 0; i < variables->size() ; i++) {
|
||||
std::string name = variables->at(i)->m_name;
|
||||
VariableModificatorExclusion *e = dynamic_cast<VariableModificatorExclusion *>(variables->at(i));
|
||||
VariableModificatorExclusion *e =
|
||||
dynamic_cast<VariableModificatorExclusion *>(variables->at(i));
|
||||
if (e != NULL) {
|
||||
if (except.empty()) {
|
||||
except = except + name;
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/utils/string.h"
|
||||
@ -96,7 +98,7 @@ class Variable {
|
||||
|
||||
class VariableModificatorExclusion : public Variable {
|
||||
public:
|
||||
VariableModificatorExclusion(std::unique_ptr<Variable> var)
|
||||
explicit VariableModificatorExclusion(std::unique_ptr<Variable> var)
|
||||
: Variable(var->m_name),
|
||||
m_var(std::move(var)) {
|
||||
m_isExclusion = true;
|
||||
@ -114,7 +116,7 @@ class VariableModificatorExclusion : public Variable {
|
||||
|
||||
class VariableModificatorCount : public Variable {
|
||||
public:
|
||||
VariableModificatorCount(std::unique_ptr<Variable> var)
|
||||
explicit VariableModificatorCount(std::unique_ptr<Variable> var)
|
||||
: Variable(var->m_name),
|
||||
m_var(std::move(var)) {
|
||||
m_isCount = true;
|
||||
|
@ -112,7 +112,7 @@ void XML::evaluate(Transaction *t,
|
||||
}
|
||||
/* Create one variable for each node in the result. */
|
||||
for (i = 0; i < nodes->nodeNr; i++) {
|
||||
char *content = NULL;
|
||||
char *content;
|
||||
content = reinterpret_cast<char *>(
|
||||
xmlNodeGetContent(nodes->nodeTab[i]));
|
||||
if (content != NULL) {
|
||||
|
@ -36,7 +36,7 @@ namespace Variables {
|
||||
*/
|
||||
class XML_NoDictElement : public Variable {
|
||||
public:
|
||||
explicit XML_NoDictElement()
|
||||
XML_NoDictElement()
|
||||
: Variable("XML"),
|
||||
m_plain("[XML document tree]"),
|
||||
m_var(&m_name, &m_plain) {
|
||||
@ -46,7 +46,7 @@ class XML_NoDictElement : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::vector<const collection::Variable *> *l) override {
|
||||
l->push_back(&m_var);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ class XML : public Variable {
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
std::vector<const collection::Variable *> *l);
|
||||
std::vector<const collection::Variable *> *l) override;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user