mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Adds support to the operator @within
This commit is contained in:
parent
218eab6417
commit
b883888c03
@ -18,24 +18,30 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
|
#include "src/macro_expansion.h"
|
||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Within::evaluate(Assay *assay) {
|
|
||||||
/**
|
bool Within::evaluate(Assay *assay, const std::string &str) {
|
||||||
* @todo Implement the operator Within.
|
bool res = false;
|
||||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#within
|
std::string paramTarget = MacroExpansion::expand(param, assay);
|
||||||
*/
|
|
||||||
return true;
|
if (str.empty()) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = paramTarget.find(str) != std::string::npos;
|
||||||
|
|
||||||
|
|
||||||
Within::Within(std::string op, std::string param, bool negation)
|
if (negation) {
|
||||||
: Operator() {
|
return !res;
|
||||||
this->op = op;
|
}
|
||||||
this->param = param;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
@ -27,8 +27,10 @@ namespace operators {
|
|||||||
class Within : public Operator {
|
class Within : public Operator {
|
||||||
public:
|
public:
|
||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
Within(std::string o, std::string p, bool i);
|
Within(std::string op, std::string param, bool negation)
|
||||||
bool evaluate(Assay *assay);
|
: Operator(op, param, negation) { }
|
||||||
|
|
||||||
|
bool evaluate(Assay *assay, const std::string &str);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
|
Loading…
x
Reference in New Issue
Block a user