Repository navigation
Conversation
|
Withdrawing: #4192 covers exactly this change — the same Filed without screening the open pull requests for the audit search first; closing #4289 for the same |
The audit log search value is handed to `like("operator", search)` and its
two sibling columns unchanged, so MyBatis-Plus builds `%<search>%` with the
caller's `%` and `_` still acting as wildcards. Searching for `100%_done`
matches any row whose operator, resource name or detail merely contains
`100` followed by any characters, and a search of `%` or `_` matches the
whole table instead of the rows that contain that character.
The same value feeds the summary and the CSV export
(`AuditService.exportLogs` reuses `findPage`), so the insight counts and the
exported file are wrong in the same way as the list view.
Escaping now happens once per query builder, with the backslash convention
already used by the message query history search, which MySQL resolves
without an `ESCAPE` clause.
d438e8f to
cf801d7
Compare
|
Reopened and rebased as requested. The rebase moved the branch from
Fresh evidence on the rebased head ( Red, Green, with the fix ( The two failures are the escaping tests ( |
|
Escaping the audit search term so Please regroup your open Studio fixes into one PR per functional domain (for example For the regroup: this is the same repository method that #4192 patches, and it adds another private |
What is the purpose of the change
The audit log search value reaches the repository unmodified and is used as a LIKE pattern over
operator,resource_nameanddetail. MyBatis-Plus wraps it as%<search>%, so the caller's%and
_keep their SQL wildcard meaning:search=%matches every row (LIKE '%%');search=_matches every row whose column is a non-empty string;search=100%_donematches any row that merely contains100followed by four arbitrarycharacters, instead of the rows that contain the literal text.
The same value drives the insight aggregates and the CSV export —
AuditService.exportLogsreusesfindPage— so the list, the summary and the exported file are all wrong in the same way, and afull-table match can push the export over its 10 000-record cap and fail it with a 400 where the
filtered subset would have fitted.
The fix escapes the search once per query builder, with the backslash convention the repository
already uses for the message query history search (
QueryHistoryService:353) — MySQL treats abackslash as the default LIKE escape character, so no
ESCAPEclause is needed and a literalbackslash in the search is matched as a literal backslash too.
Brief changelog
MybatisPlusAuditRepository: addedescapeLikeand applied it in both places that build thesearch predicate —
findPageand the sharedapplyFiltersused bysummarize/exportLogs.MybatisPlusAuditRepositoryTest: two new cases —findPagewith100%_doneandsummarizewitha_b%; both assert the bound LIKE parameters are%100\%\_done%/%a\_b\%%, on every query thesummary issues (four
selectMapsaggregates plus theselectListlookup).Verification
Red first, on the unmodified implementation with only the new tests added:
Green after the change:
Whole backend suite (
mvn -f server/pom.xml -B test):Tests run: 2153, Failures: 5, Errors: 5, Skipped: 0— the same ten ids that fail on the unmodified base6c24d2ed(
Tests run: 2151, Failures: 5, Errors: 5): eight need a POSIXshCLI this Windows machine doesnot have (
CliAgentProviderTest,ClaudeCodeAgentProviderTest) and two are theAuthCorsIntegrationTestcases aligned separately in #4217. No other test moved.Only the query wrappers are asserted, as in the existing tests of this class; no MySQL instance is
available here, so the escaping is verified at the point where the value is bound.
Fixes #4289