apache / apache/rocketmq-dashboard

[Studio][Bug] ACL user and rule search do not escape SQL LIKE wildcards

Open
#4,229 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.4k
Forks
683
Avg merge
2d 14h
Merged PRs (30d)
58

Description

## Problem

ACL inventory search treats `%` and `_` as SQL LIKE wildcards instead of literal characters:

- `GET /api/acl/users/page?keyword=` filters `username` and `access_key` with unescaped `LIKE`.
- `GET /api/acl/rules/page?principal=` / `?resource=` filter `principal` and `resource` the same way.

Usernames and ACL principals commonly contain underscores (`svc_monitor`, `prod_user`). Searching for `prod_user` therefore also matches `prodXuser`, and a trailing `%` matches any suffix — so the inventory silently returns unrelated accounts or rules.

## Evidence

`MybatisPlusAclRepository.findUserPage` (`server/src/main/java/org/apache/rocketmq/studio/instance/acl/MybatisPlusAclRepository.java:115-129`) lowercases the keyword and passes it straight into `.like(username, search).or().like(access_key, search)`.

`MybatisPlusAclRepository.ruleQuery` (`:388-398`) does the same for `principal` and `resource`.

The same class of defect was already fixed for query history (`QueryHistoryService.escapeLike`) and is being fixed for instance / audit / cloud-credential / Studio-user search; ACL inventory is the remaining high-traffic search surface with the gap.

## Impact

Operators cannot reliably look up the ACL account or rule they mean when the identifier contains `_` or `%`. In a shared Studio with many service accounts this produces wrong rows (including other accounts' access keys in the page listing) and can hide the intended rule.

## Expected behavior

User-supplied `keyword`, `principal`, and `resource` are matched literally. Escape `\`, `%`, and `_` before building the LIKE pattern (same convention as `QueryHistoryService.escapeLike`). Blank/null filters keep their current no-filter semantics.

## Acceptance criteria

- Regression tests prove a keyword such as `prod_user%` is bound as `%prod\_user\%%` rather than `%prod_user%`.
- Cover both the user page search and the rule page principal/resource search.
- Do not change the public API contract.

## Related work

#2265 / `QueryHistoryService.escapeLike` established the escape convention. Open peers: #4223 (Studio user search), instance / audit / cloud-credential LIKE PRs.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in server/src/main/java/org/apache/rocketmq/studio/instance/acl/MybatisPlusAclRepository.java, reviewing findUserPage and ruleQuery, then compare their LIKE handling with QueryHistoryService.escapeLike. Add regression coverage for user keyword and rule principal/resource searches, and verify that backslashes, percent signs, and underscores are bound literally while blank filters retain their current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authorization, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.