mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
setvar: needs review
This commit is contained in:
@@ -75,6 +75,17 @@ bool Operator::debug(Transaction *transaction, int x, std::string a) {
|
||||
}
|
||||
|
||||
|
||||
bool Operator::evaluateInternal(Transaction *transaction,
|
||||
Rule *rule, const std::string& a) {
|
||||
bool res = evaluate(transaction, rule, a);
|
||||
|
||||
if (m_negation) {
|
||||
return !res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Operator::evaluateInternal(Transaction *transaction,
|
||||
const std::string& a) {
|
||||
bool res = evaluate(transaction, a);
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#define SRC_OPERATORS_OPERATOR_H__
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
@@ -48,7 +49,14 @@ class Operator {
|
||||
}
|
||||
|
||||
bool evaluateInternal(Transaction *t, const std::string& a);
|
||||
bool evaluateInternal(Transaction *t, Rule *rule,
|
||||
const std::string& a);
|
||||
|
||||
virtual bool evaluate(Transaction *transaction, const std::string &str);
|
||||
virtual bool evaluate(Transaction *transaction, Rule *rule,
|
||||
const std::string &str) {
|
||||
return evaluate(transaction, str);
|
||||
}
|
||||
|
||||
bool m_negation;
|
||||
std::string m_match_message;
|
||||
|
@@ -20,13 +20,15 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/macro_expansion.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
|
||||
bool Rx::evaluate(Transaction *transaction, const std::string& input) {
|
||||
bool Rx::evaluate(Transaction *transaction, Rule *rule,
|
||||
const std::string& input) {
|
||||
SMatch match;
|
||||
std::list<SMatch> matches;
|
||||
|
||||
@@ -35,10 +37,16 @@ bool Rx::evaluate(Transaction *transaction, const std::string& input) {
|
||||
}
|
||||
|
||||
matches = m_re->searchAll(input);
|
||||
for (const SMatch& a : matches) {
|
||||
if (transaction) {
|
||||
if (rule && rule->getActionsByName("capture").size() > 0 && transaction) {
|
||||
int i = 0;
|
||||
matches.reverse();
|
||||
for (const SMatch& a : matches) {
|
||||
transaction->m_collections.storeOrUpdateFirst("TX",
|
||||
std::to_string(i), a.match);
|
||||
transaction->debug(7, "Added regex subexpression TX." +
|
||||
std::to_string(i) + ": " + a.match);
|
||||
transaction->m_matched.push_back(a.match);
|
||||
transaction->debug(7, "Added regex subexpression: " + a.match);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,12 @@ class Rx : public Operator {
|
||||
~Rx() {
|
||||
delete m_re;
|
||||
}
|
||||
bool evaluate(Transaction *transaction, const std::string &input);
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
const std::string &input) override;
|
||||
bool evaluate(Transaction *transaction,
|
||||
const std::string &input) override {
|
||||
return evaluate(transaction, NULL, input);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_param;
|
||||
|
Reference in New Issue
Block a user