Adds support to the strmatch operator

This commit is contained in:
Felipe Zimmerle 2015-08-10 14:03:15 -03:00
parent f62e17c67c
commit 70c2621af3
2 changed files with 13 additions and 14 deletions

View File

@ -22,20 +22,17 @@
namespace ModSecurity {
namespace operators {
bool StrMatch::evaluate(Assay *assay) {
/**
* @todo Implement the operator StrMatch.
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#strmatch
*/
return true;
bool StrMatch::evaluate(Assay *assay, const std::string &input) {
bool ret = input.find(param) != std::string::npos;
if (negation) {
return !ret;
}
return ret;
}
StrMatch::StrMatch(std::string op, std::string param, bool negation)
: Operator() {
this->op = op;
this->param = param;
}
} // namespace operators
} // namespace ModSecurity

View File

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