Adds support to negative on the contains operator

This commit is contained in:
Felipe Zimmerle 2015-07-27 16:00:44 -03:00
parent f41f9e1f0d
commit 4462fd84ec
2 changed files with 8 additions and 8 deletions

View File

@ -21,14 +21,13 @@ namespace ModSecurity {
namespace operators {
bool Contains::evaluate(Assay *assay, const std::string &input) {
return input.find(this->param) != std::string::npos;
}
bool contains = input.find(param) != std::string::npos;
Contains::Contains(std::string _op, std::string _param,
bool negation)
: Operator() {
this->op = _op;
this->param = _param;
if (negation) {
return !contains;
}
return contains;
}
} // namespace operators

View File

@ -28,7 +28,8 @@ namespace operators {
class Contains : public Operator {
public:
/** @ingroup ModSecurity_Operator */
Contains(std::string o, std::string p, bool i);
Contains(std::string op, std::string param, bool negation)
: Operator(op, param, negation) { }
bool evaluate(Assay *assay, const std::string &exp) override;
};