smengcl opened a new pull request, #8984:
URL: https://github.com/apache/hadoop/pull/8984

   Generated-by: Claude Code (Opus 5.5)
   
   JIRA: https://issues.apache.org/jira/browse/HDFS-18032
   
   ### Description of PR
   
   `HostRestrictingAuthorizationFilter` 
(`dfs.web.authentication.host.allow.rules`) used commons-net `SubnetUtils`, 
which only parses IPv4:
   
   - An IPv6 client checked against an IPv4 rule made `isInRange` throw, so the 
DataNode answered `op=OPEN` and `op=GETDELEGATIONTOKEN` with 500 instead of a 
match or 403.
   - A rule with an IPv6 network, such as `user,2001:db8::/32,/path`, failed 
filter initialization.
   
   This patch:
   
   - Makes a rule of the other address family not match, instead of throwing.
   - Accepts IPv6 networks, matched by a single entry `MachineList`, which 
supports IPv6 CIDRs since HADOOP-19962. The network must still be `*` or 
network/bits, so a bare address or a hostname is still rejected.
   - Keeps `SubnetUtils` for IPv4 networks, so IPv4 matching does not change. 
(`MachineList` counts the network and broadcast addresses as in range, the 
`SubnetUtils` setup used here does not.)
   - Says in WebHDFS.md that the network can be IPv4 or IPv6.
   
   ### How was this patch tested?
   
   New unit tests in existing classes:
   
   - `TestHostRestrictingAuthorizationFilter#testIPv4AndIPv6Rules`: IPv4 and 
IPv6 clients (including the bracketed form Jetty returns) against IPv4 and IPv6 
rules, allowed or 403.
   - `TestHostRestrictingAuthorizationFilter#testRejectsInvalidNetwork`: an 
IPv6 network with a bad prefix length, a bare IPv6 address and a bare IPv4 
address still fail initialization.
   - `TestHostRestrictingAuthorizationFilterHandler#testIPv6Client`: through 
the Netty handler, an IPv6 client passes an IPv4 rule on its way to a matching 
`*` rule, and gets 403 for a path only an IPv4 rule covers. Without the fix 
both requests get 500.
   
   Both test classes pass locally with JDK 17, and the new tests fail without 
the fix. Checkstyle reports nothing new.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   
   ### AI Tooling
   
   - [x] The PR includes the phrase "Contains content generated by Claude Code".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Code.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to