zjncs opened a new pull request, #4192:
URL: https://github.com/apache/rocketmq-dashboard/pull/4192

   ### Motivation
   
   The operation-audit search box passes the raw term straight into `LIKE` 
clauses over `operator`, `resource_name` and `detail` 
(`MybatisPlusAuditRepository.findPage` and the shared `applyFilters` used by 
`summarize`/`exportLogs`). Because `%` and `_` are SQL LIKE wildcards:
   
   - searching for an operator or topic name containing `%` (e.g. `100%`) 
matches every row whose text merely *ends* with `100`, and
   - `_` matches any single character,
   
   so the audit page and its summary cards can report wildly wrong results for 
these inputs.
   
   ### Changes
   
   - Add a private `escapeLike` helper (same behaviour as the existing 
`QueryHistoryService.escapeLike`) and apply it to the search term in both 
`findPage` and `applyFilters`, so the page query, `summarize` aggregates and 
`exportLogs` all match the term literally.
   
   ### Verification
   
   `MybatisPlusAuditRepositoryTest` — two new tests:
   
   - `findPageEscapesLikeWildcardsInTheSearchTermTest`: searching `100%_ok` 
binds `%100\%\_ok%` instead of the unescaped pattern.
   - `summarizeEscapesLikeWildcardsInEveryAggregateQueryTest`: every aggregate 
query built by `summarize` (result counts, distinct operators, both hotspot 
GROUP BYs, latest-at lookup) binds the escaped literal.
   
   Before the fix both new tests fail; after it the class is green (11/11).
   
   ```
   $ mvn -f server/pom.xml test -Dtest='MybatisPlusAuditRepositoryTest'
   (before) Tests run: 11, Failures: 2, Errors: 0
   (after)  Tests run: 11, Failures: 0, Errors: 0
   ```


-- 
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]

Reply via email to