From 0ab3bc62d64f4908dd0e3642ea188cb39eb3e112 Mon Sep 17 00:00:00 2001 From: Terrance Wood Date: Sun, 10 Nov 2019 01:10:49 -0800 Subject: [PATCH] Fixed exact whitelist matches broken after introducing CIDR notation. --- .../gwt/whitelist/WhitelistVerifier.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/gwt/whitelist/WhitelistVerifier.java b/src/main/java/org/jenkinsci/plugins/gwt/whitelist/WhitelistVerifier.java index 1efd948..5e092a0 100644 --- a/src/main/java/org/jenkinsci/plugins/gwt/whitelist/WhitelistVerifier.java +++ b/src/main/java/org/jenkinsci/plugins/gwt/whitelist/WhitelistVerifier.java @@ -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; @@ -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;