Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1020: Perform some additional null checks in restriction verification service. #1022

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ public static RestrictionType allowedByTimeRestrictions(String allowedTimeString
public static RestrictionType allowedByHostRestrictions(String allowedHostsString,
String deniedHostsString, String remoteAddress) {

// Convert the string to a HostName
HostName remoteHostName = new HostName(remoteAddress);

// If attributes do not exist or are empty then the action is allowed.
if ((allowedHostsString == null || allowedHostsString.isEmpty())
&& (deniedHostsString == null || deniedHostsString.isEmpty()))
Expand All @@ -152,19 +149,27 @@ public static RestrictionType allowedByHostRestrictions(String allowedHostsStrin
return RestrictionType.IMPLICIT_DENY;
}

// Convert the string to a HostName
HostName remoteHostName = new HostName(remoteAddress);

// Split denied hosts attribute and process each entry, checking them
// against the current remote address, and returning false if a match is
// found.
// against the current remote address, and returning a deny restriction
// if a match is found, or if an error occurs in processing a host in
// the list.
List<HostName> deniedHosts = HostRestrictionParser.parseHostList(deniedHostsString);
for (HostName hostName : deniedHosts) {

try {
if (hostName.isAddress() && hostName.toAddress().contains(remoteHostName.asAddress()))
if (hostName.isAddress()
&& hostName.toAddress().contains(remoteHostName.asAddress())) {
return RestrictionType.EXPLICIT_DENY;
}

else
else {
for (IPAddress currAddr : hostName.toAllAddresses())
if (currAddr.matches(remoteHostName.asAddressString()))
return RestrictionType.EXPLICIT_DENY;
}
}
catch (UnknownHostException | HostNameException e) {
LOGGER.warn("Unknown or invalid host in denied hosts list: \"{}\"", hostName);
Expand Down
Loading