Repository navigation
[ISSUE #11544] fix(auth): guard against null environment in Environment#isMatch - #11545
leaveWhite9088 wants to merge 2 commits into
Conversation
…ironment#isMatch
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #11545 +/- ##
=============================================
+ Coverage 49.86% 49.89% +0.02%
- Complexity 14454 14459 +5
=============================================
Files 1391 1391
Lines 103432 103432
Branches 13550 13550
=============================================
+ Hits 51573 51604 +31
+ Misses 45636 45600 -36
- Partials 6223 6228 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
qingli9374
left a comment
There was a problem hiding this comment.
The integration test covers the user-visible ACL behavior, and the null guard itself is
correct. One follow-up would make the coverage less environment-dependent: add a small model
test in authorization/model/EnvironmentTest that asserts a constrained environment returns
false for a null request environment, while an environment without an IP constraint still
returns true. The current handler test is skipped on macOS through MixAll.isMac(), so the
direct model test also protects the changed branch in local runs that do not exercise the
ACL metadata setup.
…onstrained environment matching
|
Thanks @qingli9374 for the suggestion! I've added \EnvironmentTest\ under \�uth/src/test/java/org/apache/rocketmq/auth/authorization/model/\ covering both constrained and unconstrained \Environment#isMatch\ cases with |
Which Issue(s) This PR Fixes
Brief Description
When an ACL
PolicyEntrydefines a source IP restriction andDefaultAuthorizationContext#getSourceIp()isnullor empty (for example, when a Netty channel has no remote address or a non-TCP gRPC transport omitsGrpcConstants.REMOTE_ADDRESS),Environment.of(context.getSourceIp())returnsnull, causingEnvironment#isMatch(null)inAclAuthorizationHandler#matchPolicyEntriesto throwNullPointerExceptioninstead of returningfalse.This PR adds a null check for
environmentinEnvironment#isMatchso it returnsfalse, and adds a unit test inAclAuthorizationHandlerTest.How Did You Test This Change?
mvn test -pl auth -Dtest=AclAuthorizationHandlerTest(Checkstyle: 0 violations, SpotBugs: 0 errors, Tests run: 11, Failures: 0, Errors: 0).