Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13450
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Feb 29, 2024
1 parent 4cbceb9 commit f328a72
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/framework/ConfigurationValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8037,45 +8037,54 @@ bool ExternalValijsonFormatChecker(const std::string &format, const std::string
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid CIDR IPv4 block", value));
return false;
} else if (format == "uc-cidr6") {
if (IsCIDRv6(value))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid CIDR IPv6 block", value));
return false;
} else if (format == "uc-cidr") {
if (IsCIDR(value))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid CIDR block", value));
return false;
} else if (format == "uc-mac") {
if (std::regex_match(value, mac_regex))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid MAC address", value));
return false;
} else if (format == "uc-timeout") {
if (std::regex_match(value, uc_timeout_regex))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid timeout value", value));
return false;
} else if (format == "uc-host") {
if (IsIP(value))
return true;
if (std::regex_match(value, host_regex))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid hostname", value));
return false;
} else if (format == "fqdn" || format == "uc-fqdn") {
if (std::regex_match(value, host_regex))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid FQDN", value));
return false;
} else if (format == "uc-base64") {
std::string s{value};
Poco::trimInPlace(s);
if ((s.size() % 4 == 0) && std::regex_match(s, b64_regex))
return true;
bool valid = value.size() % 4 == 0 && std::all_of(value.begin(), value.end(), [](char c) {
return std::isalnum(c) || c == '+' || c == '/' || c == '=';
});
if (valid)
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid base 64 value", value));
results->pushError(context, fmt::format("{} is not a valid base 64 value", "..."));
return false;
} else if (format == "uri") {
try {
Poco::URI uri(value);
Expand All @@ -8084,6 +8093,7 @@ bool ExternalValijsonFormatChecker(const std::string &format, const std::string
}
if (results)
results->pushError(context, fmt::format("{} is not a valid URL", value));
return false;
} else if (format == "uc-portrange") {
try {
if (IsPortRangeIsValid(value))
Expand All @@ -8092,11 +8102,13 @@ bool ExternalValijsonFormatChecker(const std::string &format, const std::string
}
if (results)
results->pushError(context, fmt::format("{} is not a valid post range", value));
return false;
} else if (format == "ip") {
if (IsIP(value))
return true;
if (results)
results->pushError(context, fmt::format("{} is not a valid IP address", value));
return false;
}
return true;
}
Expand Down

0 comments on commit f328a72

Please sign in to comment.