Addressing comments#253
Open
KJ202 wants to merge 7 commits into
Open
Conversation
Co-authored-by: Gábor Vaspöri <gabor.vaspori@gmail.com> Co-authored-by: Kian Jamali <kianjamali123@gmail.com> Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Previously the terminology blurred allow/deny into the matching APIs which was confusing. The API now consistently uses matching logic.
This is more consistent with the matches(String) method and it allows APIs like ServerHttpRequest.getRemoteAddress() to be passed in without needing to check if the value is null.
IpAddressServerWebExchangeMatcher was used for WebFlux applications which used IpAddressMatcher. This was likely problematic because IpAddressMatcher contains servlet APIs in it's method signatures. Even if those specific methods aren't used by IpAddressServerWebExchangeMatcher it can cause classpath issues for webflux applications. This commit switches to using InetAddressMatcher which does not contain any dependencies on the ServletAPI
…back - Use `isLinkLocalAddress()` to correctly identify link-local addresses (e.g., 169.254.x.x) as internal. - Use `isSiteLocalAddress()` to correctly match the entire 172.16.0.0/12 subnet and rely on standard JVM checks for IPv4-mapped IPv6 addresses. - Retain custom matching for Unique Local Addresses (fc00::/7) due to JVM limitations with RFC 4193. - Add defensive blank string checking in `InetAddressParser.isIpAddress()`.
3c8c183 to
d693ad9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses code review feedback from spring-projects#18634 by refactoring and expanding the internal IP address matching and parsing logic.
A Test-Driven Development (TDD) approach was used to ensure all specific address spaces mentioned in the feedback (169.254.x.x, 172.16.x.x/12, etc.) are caught accurately while improving overall code simplicity and safety.
Changes Incorporated
Testing