-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
add java doc warning comment into ipAddressMatcher for potential DNS resolution #13621
add java doc warning comment into ipAddressMatcher for potential DNS resolution #13621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the new JavaDoc adds anything that wasn't already said earlier. The existing JavaDoc says:
* 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).
so the correct format is already indicated.
That said, I like your second idea to validate the parameters. Will you please change the code to validate that the first character is [
, :
, or a digit? Something like this:
Assert.isTrue(ipAddress.charAt(0) == `[` ||
ipAddress.charAt(0) == ':' ||
Character.digit(ipAddress.charAt(0), 16), "ipAddress must start with a [, :, or a hexadecimal digit");
This is needed in the constructor as well as the matches(String)
method when preparing the address
for comparison.
Hi, @maoling. Are you able to make the requested changes? |
Hi guys, hope you're doing well Since no updates has been made in this pull request, I went ahead and created this PR to address the changes suggested. Let me know if its ok for you |
Closing in favor of #14491 |
I went through everything to get it to fit with Spring's docuemntation standard. Lots of small changes for punctuation, grammar, usage, voice, and so on. Also added some links, mostly to the API Javadoc.
In our use case, our api gateway used
ipAddressMatcher
util to check whether a request's ip is in the ip-black list, but sometimes, theremoteAddress
orX-Forwarded-For
is in a bad format(maybe malicious requests) as following. They're not Ip, but hostname. ipAddressMatcher calls theInetAddress#getByNam
e which causes a DNS resolution, then the cloud vm alarms with this behavior.This PR just adds java doc warning comment, If your guys prefer the implementation by removing using the
InetAddress#getByName
and check ipv4/ipv6 inside, I will create another PR to rewrite it.