Adds initial support to chained rules

This commit is contained in:
Felipe Zimmerle
2015-07-21 10:49:43 -03:00
parent 9c066e3198
commit 4f20f5bf74
8 changed files with 122 additions and 4 deletions

View File

@@ -34,9 +34,33 @@ int Driver::addSecRule(ModSecurity::Rule *rule) {
/** TODO: return an error message */
return -1;
}
int size = this->rules[rule->phase].size();
if (size == 0) {
this->rules[rule->phase].push_back(rule);
return true;
}
ModSecurity::Rule *lastRule = this->rules[rule->phase][size-1];
if (lastRule->chained && lastRule->chainedRule == NULL) {
lastRule->chainedRule = rule;
return true;
}
if (lastRule->chained && lastRule->chainedRule != NULL) {
ModSecurity::Rule *a = lastRule->chainedRule;
while (a->chained && a->chainedRule != NULL) {
a = a->chainedRule;
}
if (a->chained && a->chainedRule == NULL) {
a->chainedRule = rule;
return true;
}
}
this->rules[rule->phase].push_back(rule);
return 1;
return true;
}

View File

@@ -59,7 +59,7 @@ OPERATORNOARG (?i:@detectSQLi|@detectXSS|@geoLookup|@validateUrlEncoding|@valida
TRANSFORMATION t:(lowercase|urlDecodeUni|urlDecode|none|compressWhitespace|removeWhitespace|replaceNulls|removeNulls|htmlEntityDecode|jsDecode|cssDecode|trim)
VARIABLE (?i:INBOUND_DATA_ERROR|FULL_REQUEST|FILES|AUTH_TYPE|ARGS_NAMES|ARGS|QUERY_STRING|REMOTE_ADDR|REQUEST_BASENAME|REQUEST_BODY|REQUEST_COOKIES_NAMES|REQUEST_COOKIES|REQUEST_FILENAME|REQUEST_HEADERS_NAMES|REQUEST_HEADERS|REQUEST_METHOD|REQUEST_PROTOCOL|REQUEST_URI|RESPONSE_BODY|RESPONSE_CONTENT_LENGTH|RESPONSE_CONTENT_TYPE|RESPONSE_HEADERS_NAMES|RESPONSE_HEADERS|RESPONSE_PROTOCOL|RESPONSE_STATUS|TX|GEO)
VARIABLE (?i:MATCHED_VAR|INBOUND_DATA_ERROR|FULL_REQUEST|FILES|AUTH_TYPE|ARGS_NAMES|ARGS|QUERY_STRING|REMOTE_ADDR|REQUEST_BASENAME|REQUEST_BODY|REQUEST_COOKIES_NAMES|REQUEST_COOKIES|REQUEST_FILENAME|REQUEST_HEADERS_NAMES|REQUEST_HEADERS|REQUEST_METHOD|REQUEST_PROTOCOL|REQUEST_URI|RESPONSE_BODY|RESPONSE_CONTENT_LENGTH|RESPONSE_CONTENT_TYPE|RESPONSE_HEADERS_NAMES|RESPONSE_HEADERS|RESPONSE_PROTOCOL|RESPONSE_STATUS|TX|GEO)
RUN_TIME_VAR_DUR (?i:DURATION)
RUN_TIME_VAR_ENV (?i:ENV)
RUN_TIME_VAR_BLD (?i:MODSEC_BUILD)