mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 19:24:26 +03:00
Aug 20th update
This commit is contained in:
@@ -299,7 +299,16 @@ MatchQuery::matchAttributes(
|
||||
{
|
||||
auto &type = condition_type;
|
||||
bool negate = type == MatchQuery::Conditions::NotEquals || type == MatchQuery::Conditions::NotIn;
|
||||
bool match = isRegEx() ? matchAttributesRegEx(values, matched_override_keywords) : matchAttributesString(values);
|
||||
bool match = false;
|
||||
|
||||
if (isIP()) {
|
||||
match = matchAttributesIp(values);
|
||||
} else if (isRegEx()) {
|
||||
match = matchAttributesRegEx(values, matched_override_keywords);
|
||||
} else {
|
||||
match = matchAttributesString(values);
|
||||
}
|
||||
|
||||
return negate ? !match : match;
|
||||
}
|
||||
|
||||
@@ -340,8 +349,26 @@ MatchQuery::matchAttributesString(const set<string> &values) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MatchQuery::matchAttributesIp(const set<string> &values) const
|
||||
{
|
||||
for (const IPRange &rule_ip_range : ip_addr_value) {
|
||||
for (const string &requested_value : values) {
|
||||
IpAddress ip_addr = IPUtilities::createIpFromString(requested_value);
|
||||
if (IPUtilities::isIpAddrInRange(rule_ip_range, ip_addr)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
MatchQuery::isRegEx() const
|
||||
{
|
||||
return key != "protectionName";
|
||||
}
|
||||
|
||||
bool
|
||||
MatchQuery::isIP() const
|
||||
{
|
||||
return key == "sourceIP" || key == "destinationIP";
|
||||
}
|
||||
|
Reference in New Issue
Block a user