Skip to content

Commit

Permalink
throw unknownhostexception instead of illegal argument exception
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan committed Sep 25, 2024
1 parent 7c8881a commit b43fa9b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ fun validateUrl(urlString: String) {

fun validateUrlHost(urlString: String, hostDenyList: List<String>) {
val url = URL(urlString)
require(org.opensearch.notifications.spi.utils.getResolvedIps(url.host).isNotEmpty()) {
"Host could not be resolved to a valid Ip address"

if (org.opensearch.notifications.spi.utils.getResolvedIps(url.host).isEmpty()) {
throw UnknownHostException("Host could not be resolved to a valid Ip address")
}

require(!org.opensearch.notifications.spi.utils.isHostInDenylist(urlString, hostDenyList)) {
"Host of url is denied, based on plugin setting [notification.core.http.host_deny_list]"
}
Expand Down

0 comments on commit b43fa9b

Please sign in to comment.