mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Adds method init to Operator class
This commit is contained in:
parent
7b4554216e
commit
c2d33823f5
@ -35,11 +35,12 @@ class Operator {
|
|||||||
param(param),
|
param(param),
|
||||||
negation(negation) { }
|
negation(negation) { }
|
||||||
|
|
||||||
|
virtual ~Operator() { }
|
||||||
std::string op;
|
std::string op;
|
||||||
std::string param;
|
std::string param;
|
||||||
bool negation;
|
bool negation;
|
||||||
|
|
||||||
|
virtual bool init(const char **error) { return true; }
|
||||||
virtual bool evaluate(Assay *assay);
|
virtual bool evaluate(Assay *assay);
|
||||||
virtual bool evaluate(Assay *assay, const std::string &str);
|
virtual bool evaluate(Assay *assay, const std::string &str);
|
||||||
static Operator *instantiate(std::string op);
|
static Operator *instantiate(std::string op);
|
||||||
|
@ -261,8 +261,14 @@ expression:
|
|||||||
audit_log
|
audit_log
|
||||||
| DIRECTIVE SPACE variables SPACE OPERATOR SPACE QUOTATION_MARK actions QUOTATION_MARK
|
| DIRECTIVE SPACE variables SPACE OPERATOR SPACE QUOTATION_MARK actions QUOTATION_MARK
|
||||||
{
|
{
|
||||||
|
Operator *op = Operator::instantiate($5);
|
||||||
|
const char *error = NULL;
|
||||||
|
if (op->init(&error) == false) {
|
||||||
|
driver.parserError << error;
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
Rule *rule = new Rule(
|
Rule *rule = new Rule(
|
||||||
/* op */ Operator::instantiate($5),
|
/* op */ op,
|
||||||
/* variables */ $3,
|
/* variables */ $3,
|
||||||
/* actions */ $8
|
/* actions */ $8
|
||||||
);
|
);
|
||||||
|
@ -54,9 +54,11 @@ void print_help() {
|
|||||||
|
|
||||||
|
|
||||||
void perform_unit_test(UnitTest *t, ModSecurityTestResults<UnitTest>* res) {
|
void perform_unit_test(UnitTest *t, ModSecurityTestResults<UnitTest>* res) {
|
||||||
|
const char *error = NULL;
|
||||||
ModSecurity::operators::Operator *op =
|
ModSecurity::operators::Operator *op =
|
||||||
ModSecurity::operators::Operator::instantiate("\"@" + t->name + \
|
ModSecurity::operators::Operator::instantiate("\"@" + t->name + \
|
||||||
" " + t->param + "\"");
|
" " + t->param + "\"");
|
||||||
|
op->init(&error);
|
||||||
|
|
||||||
int ret = op->evaluate(NULL, t->input);
|
int ret = op->evaluate(NULL, t->input);
|
||||||
if (ret != t->ret) {
|
if (ret != t->ret) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user