unbridled-41 opened a new pull request, #5942:
URL: https://github.com/apache/rocketmq-dashboard/pull/5942

   ### Which Issue(s) This PR Fixes
   
   Fixes #5941
   
   ### Problem / Evidence
   
   `cleanupLogs` deleted rows and recorded nothing:
   
   ```java
   // before
   log.info("Cleaning up audit logs older than {} days", beforeDays);
   return auditRepository.deleteBefore(cutoff, CLEANUP_BATCH_SIZE, 
CLEANUP_MAX_BATCHES);
   ```
   
   ```
   AuditServiceTest#cleanupLogsRecordsWhatItDeletedTest
   Wanted but not invoked: auditRepository.save(...)
   ```
   
   Every sibling destructive operation records one (alert bulk delete, DLQ 
resend, cloud-credential delete, certificate delete, instance delete), so this 
endpoint - the only one that erases audit evidence - was the exception, and the 
scheduled sweep that reuses the method inherits the gap.
   
   ### Root cause / Fix
   
   The method returned its count without recording the operation. Record 
`CLEANUP_AUDIT_LOGS` (resource `AUDIT_LOG`) with `beforeDays` and the deleted 
count when rows were removed; a no-op call stays silent.
   
   ### Priority and scoring
   
   **PRIORITY 45** — impact 18/40 (audit evidence can be erased without any 
record of the erasure), blast radius 8/20 (an admin action, plus the scheduled 
sweep), reproducibility 20/20 (deterministic, pinned by tests), maintenance 
value -1/20 rounded to 0 (novel compliance property, no structural gain).
   
   **FIX_CONFIDENCE 75** — the audit service can record through its own method, 
and the new row is written after the delete, so it cannot be pruned by the same 
call (the cutoff is at least a day old).
   
   ### Tests
   
   `cd server && mvn -o -B -ntp test 
-Dtest='org.apache.rocketmq.studio.ops.audit.**,AuditControllerTest'` -> `Tests 
run: 45, Failures: 0, Errors: 0`.
   
   | Test | Before | After |
   |---|---|---|
   | `AuditServiceTest#cleanupLogsRecordsWhatItDeletedTest` | FAIL (`save` 
never invoked) | PASS (operation, detail and result asserted) |
   | `AuditServiceTest#cleanupLogsRecordsNothingWhenNothingWasDeletedTest` | 
PASS (guard) | PASS |
   
   `mvn -o -B -ntp checkstyle:check` passes.
   
   ### Risk
   
   One extra audit row per non-empty cleanup; the row's timestamp is after the 
delete and well inside the retention window, so it is not removed by the same 
call.


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