mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 11:16:33 +03:00
Adds support to MATCHED_VARS variable
This commit is contained in:
@@ -1139,6 +1139,10 @@ bool Assay::update_variable_first(std::string var, const std::string &value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Assay::delete_variable(std::string key) {
|
||||
this->m_variables_strings.erase(key);
|
||||
}
|
||||
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
Assay::resolve_variable(std::string var) {
|
||||
|
@@ -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: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)
|
||||
VARIABLE (?i:MATCHED_VAR|MATCHED_VARS|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)
|
||||
|
@@ -113,15 +113,19 @@ bool Rule::evaluate(Assay *assay) {
|
||||
assay->debug(4, "Running action: " + a->action);
|
||||
a->evaluate(assay);
|
||||
}
|
||||
|
||||
if (this->chained && this->chainedRule == NULL) {
|
||||
assay->debug(4, "Rule is marked as chained but there isn't a subsequent rule.");
|
||||
}
|
||||
if (this->chained && this->chainedRule != NULL) {
|
||||
assay->debug(4, "Executing chained rule.");
|
||||
if (assay->update_variable_first("MATCHED_VAR",
|
||||
value) == false) {
|
||||
assay->store_variable("MATCHED_VAR", value);
|
||||
}
|
||||
assay->store_variable("MATCHED_VARS:" + v.first, value);
|
||||
this->chainedRule->evaluate(assay);
|
||||
assay->update_variable_first("MATCHED_VAR", "");
|
||||
assay->delete_variable("MATCHED_VARS:" + v.first);
|
||||
}
|
||||
} else {
|
||||
assay->debug(4, "Rule returned 0.");
|
||||
|
Reference in New Issue
Block a user