Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Same LIKE-wildcard escape pattern as #4233, applied to ACL user/rule search. Clean implementation with correct escape ordering and good test coverage including the svc_monitor underscore case.
Findings
- [Info]
MybatisPlusAclRepository.java:399— Same duplication note as #4233:escapeLikeis now copy-pasted in 4+ locations. A shared utility would prevent subtle divergence.
LGTM.
lizhimins
left a comment
There was a problem hiding this comment.
Same single item as on #4224 and #4233: replace the private escapeLike copy with the shared utility in common/util, and add an explicit ESCAPE clause rather than relying on MySQL's implicit backslash (H2, used by five tests in this suite, has no default LIKE escape character).
Your own comment here says it mirrors QueryHistoryService.escapeLike, which is the duplication we want removed. Please keep the tests.
Use the shared SqlLikeUtil helper with an explicit ESCAPE clause so underscore-bearing principals/resources match literally on both MySQL and H2. Fixes apache#4229 Signed-off-by: halaxy <63827956+89799969@users.noreply.github.com>
0223319 to
26a5cd8
Compare
|
@lizhimins Following up - shared |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. Code changes look good.
Automated review by github-manager-bot
What is the purpose of the change
Fixes #4229.
ACL inventory search treats
%and_as SQL LIKE wildcards instead of literal characters:GET /api/acl/users/page?keyword=filtersusernameandaccess_keywith unescapedLIKE(MybatisPlusAclRepository.findUserPage).GET /api/acl/rules/page?principal=/?resource=filterprincipalandresourcethe same way (MybatisPlusAclRepository.ruleQuery).Usernames and ACL principals commonly contain underscores (
svc_monitor,prod_user). Searching forprod_usertherefore also matchesprodXuser, and a trailing%matches any suffix — so the inventory silently returns unrelated accounts or rules.Brief changelog
escapeLikehelper (same behaviour as the existingQueryHistoryService.escapeLike) and apply it to user-page keywords and rule-page principal/resource filters.prod_user%/svc_monitor%is escaped (%prod\_user\%%) rather than treated as a wildcard pattern.Verifying this change
Checkstyle: 0 violations (module validate phase).
Before the fix the two new tests fail because the bound parameters are
%prod_user%/%svc_monitor%; after it they bind%prod\_user\%%/%svc\_monitor\%%.Related peers: #4192–#4194 (audit / instance / cloud-credential LIKE escape), #4223/#4224 (Studio user search).