mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Adds support to the beginsWith operator
This commit is contained in:
parent
209a3db47f
commit
9a7506f9e9
@ -23,22 +23,22 @@ namespace ModSecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
|
|
||||||
|
bool BeginsWith::evaluate(Assay *assay, const std::string &str) {
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
bool BeginsWith::evaluate(Assay *assay) {
|
if (str.size() < param.size()) {
|
||||||
/**
|
ret = false;
|
||||||
* @todo Implement the operator BeginsWith.
|
} else if (!str.compare(0, param.size(), param)) {
|
||||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#beginswith
|
ret = true;
|
||||||
*/
|
}
|
||||||
return true;
|
|
||||||
|
if (negation) {
|
||||||
|
return !ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BeginsWith::BeginsWith(std::string op, std::string param,
|
|
||||||
bool negation)
|
|
||||||
: Operator() {
|
|
||||||
this->op = op;
|
|
||||||
this->param = param;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
} // namespace ModSecurity
|
} // namespace ModSecurity
|
||||||
|
@ -27,8 +27,10 @@ namespace operators {
|
|||||||
class BeginsWith : public Operator {
|
class BeginsWith : public Operator {
|
||||||
public:
|
public:
|
||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
BeginsWith(std::string o, std::string p, bool i);
|
BeginsWith(std::string op, std::string param, bool negation)
|
||||||
bool evaluate(Assay *assay);
|
: Operator(op, param, negation) { }
|
||||||
|
|
||||||
|
bool evaluate(Assay *assay, const std::string &str) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace operators
|
} // namespace operators
|
||||||
|
Loading…
x
Reference in New Issue
Block a user