Aug 20th update

This commit is contained in:
Ned Wright
2024-08-21 08:42:14 +00:00
parent ca31aac08a
commit 110f0c8bd2
13 changed files with 155 additions and 15 deletions

View File

@@ -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";
}