Skip to content

[ISSUE #11673] fix(common): match equivalent IPv6 literals in ACL source IP check - #11674

Open
amalsaidov wants to merge 1 commit into
apache:developfrom
amalsaidov:fix/ipv6-literal-acl-source-ip
Open

amalsaidov wants to merge 1 commit into
apache:developfrom
amalsaidov:fix/ipv6-literal-acl-source-ip

Conversation

@amalsaidov

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #11673

Brief Description

IPAddressUtils#isIPInRange compared a single-IP ACL entry with the client IP as plain strings, so ::1 never matched a client reported as 0:0:0:0:0:0:0:1 or [0:0:0:0:0:0:0:1] (the InetSocketAddress#toString() form on JDK 14+).

When the strings differ, the method now compares the parsed addresses, provided both sides are valid IP literals (one pair of [] around the client IP is stripped first). Non-IP values are never resolved and still return false, so behaviour for IPv4 and invalid input is unchanged.

How Did You Test This Change?

Added IPAddressUtilsTest#isIPInRangeShouldMatchEquivalentIPv6Literals covering compressed, full, bracketed and upper-case forms, plus negative cases (different address, non-IP string, different IPv4). It fails before the change and passes after; mvn -pl common -Dtest=IPAddressUtilsTest test is green.

…ange

A single-IP ACL entry was compared to the client address as a plain string,
so '::1' never matched a client reported as '0:0:0:0:0:0:0:1' or
'[0:0:0:0:0:0:0:1]' (the form InetSocketAddress#toString uses on JDK 14+).
Fall back to comparing the parsed addresses when both sides are IP literals.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.38%. Comparing base (b58f191) to head (a4207e1).

Files with missing lines Patch % Lines
...g/apache/rocketmq/common/utils/IPAddressUtils.java 57.14% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11674      +/-   ##
=============================================
- Coverage      51.41%   51.38%   -0.04%     
+ Complexity     15065    15060       -5     
=============================================
  Files           1391     1391              
  Lines         103941   103947       +6     
  Branches       13645    13648       +3     
=============================================
- Hits           53444    53408      -36     
- Misses         44254    44284      +30     
- Partials        6243     6255      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ACL sourceIps with a single IPv6 address never matches IPv6 clients

2 participants