Skip to content

Commit

Permalink
Fixed exact whitelist matches broken after introducing CIDR notation.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTekton committed Nov 10, 2019
1 parent 48e3063 commit 0ab3bc6
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ static boolean verifyIP(final String remoteHost, final String whitelistHost)
/** Returns true if whitelistHost contains remoteHost; supports ip/cidr. */
static Boolean whitelistContains(final String remoteHost, final String whitelistHost)
throws WhitelistException {
Boolean isMatched = false;

if (whitelistHost.equalsIgnoreCase(remoteHost)) {
isMatched = true;
return true;
}

Boolean isCIDR = false;
Expand All @@ -126,11 +124,17 @@ static Boolean whitelistContains(final String remoteHost, final String whitelist
}
}

if (isCIDR || isRange) {
whitelistHostIP = hostParts[0];
isMatched = verifyCIDR(remoteHost, whitelistHost, whitelistHostIP);
} else {
isMatched = verifyIP(remoteHost, whitelistHost);
Boolean isMatched = false;

try {
if (isCIDR || isRange) {
whitelistHostIP = hostParts[0];
isMatched = verifyCIDR(remoteHost, whitelistHost, whitelistHostIP);
} else {
isMatched = verifyIP(remoteHost, whitelistHost);
}
} catch (Exception e) {
isMatched = false;
}

return isMatched;
Expand Down

0 comments on commit 0ab3bc6

Please sign in to comment.