Conversation
…nd rows containing % or _ The audit search box feeds its raw term into LIKE clauses over operator / resource_name / detail, so a search like '100%' silently matches every row whose operator/name/detail ends with '100', and '_' matches any single character. Escape the LIKE wildcards before building the wrapper, mirroring the existing QueryHistoryService.escapeLike behaviour, in both the page query and the summarize/export filter path. Signed-off-by: zjncs <18910855655@163.com>
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Fixes LIKE wildcard escaping in operation-audit search so that % and _ in user-typed search terms are matched literally rather than interpreted as SQL patterns. The escapeLike() helper correctly escapes backslash first, then the two wildcards — this ordering prevents double-escaping. Tests verify both the escaped parameter value and the query wrapper behavior.
Clean, focused fix. LGTM.
Automated review by github-manager-bot
|
Closing as part of consolidating the LIKE-escape work. The escaping is needed, but this patch adds a private See #4236: we asked for the shared |
Motivation
The operation-audit search box passes the raw term straight into
LIKEclauses overoperator,resource_nameanddetail(MybatisPlusAuditRepository.findPageand the sharedapplyFiltersused bysummarize/exportLogs). Because%and_are SQL LIKE wildcards:%(e.g.100%) matches every row whose text merely ends with100, and_matches any single character,so the audit page and its summary cards can report wildly wrong results for these inputs.
Changes
escapeLikehelper (same behaviour as the existingQueryHistoryService.escapeLike) and apply it to the search term in bothfindPageandapplyFilters, so the page query,summarizeaggregates andexportLogsall match the term literally.Verification
MybatisPlusAuditRepositoryTest— two new tests:findPageEscapesLikeWildcardsInTheSearchTermTest: searching100%_okbinds%100\%\_ok%instead of the unescaped pattern.summarizeEscapesLikeWildcardsInEveryAggregateQueryTest: every aggregate query built bysummarize(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).