mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds support to the @eq operator
This commit is contained in:
parent
2f1bcf6cb9
commit
f62e17c67c
@ -22,21 +22,32 @@
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
bool Eq::evaluate(Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the operator Eq.
|
||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#eq
|
||||
*/
|
||||
return true;
|
||||
|
||||
bool Eq::evaluate(Assay *assay, const std::string &input) {
|
||||
int p = 0;
|
||||
int i = 0;
|
||||
bool eq = false;
|
||||
|
||||
try {
|
||||
p = std::stoi(param);
|
||||
} catch (...) {
|
||||
p = 0;
|
||||
}
|
||||
try {
|
||||
i = std::stoi(input);
|
||||
} catch (...) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
eq = p == i;
|
||||
|
||||
if (negation) {
|
||||
return !eq;
|
||||
}
|
||||
|
||||
return eq;
|
||||
}
|
||||
|
||||
|
||||
Eq::Eq(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->op = op;
|
||||
this->param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace ModSecurity
|
||||
|
@ -27,8 +27,10 @@ namespace operators {
|
||||
class Eq : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Eq(std::string o, std::string p, bool i);
|
||||
bool evaluate(Assay *assay);
|
||||
Eq(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
bool evaluate(Assay *assay, const std::string &input) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
Loading…
x
Reference in New Issue
Block a user