Skip to content

add java doc warning comment into ipAddressMatcher for potential DNS resolution #13621

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

Closed
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 @@ -44,7 +44,7 @@ public final class IpAddressMatcher implements RequestMatcher {
* Takes a specific IP address or a range specified using the IP/Netmask (e.g.
* 192.168.1.0/24 or 202.24.0.0/14).
* @param ipAddress the address or range of addresses from which the request must
* come.
* come. Note: ipAddress should not be a hostname to avoid the DNS resolution for potential security issue
*/
public IpAddressMatcher(String ipAddress) {
if (ipAddress.indexOf('/') > 0) {
Expand All @@ -65,6 +65,10 @@ public boolean matches(HttpServletRequest request) {
return matches(request.getRemoteAddr());
}

/**
* match whether address is in the range of ipAddress
* @param address which is for Ip range check. Note: address should not be a hostname to avoid the DNS resolution for potential security issue
*/
public boolean matches(String address) {
InetAddress remoteAddress = parseAddress(address);
if (!this.requiredAddress.getClass().equals(remoteAddress.getClass())) {
Expand Down