[Bug] ThreatEventController.getEvents ignores deviceAgentId filter when severity is set #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Confirmed defect
ThreatEventController.getEventsfilters by only ONE parameter at a time due to early-return branch ordering. Whenseverityis present, the method returns before ever evaluatingdeviceAgentId, so the device filter is silently ignored whenever a severity is also selected.Code refs (confirmed by reading)
src/main/java/com/hiveops/aria/controller/ThreatEventController.java, methodgetEvents:if (severity != null) { return eventRepository.findBySeverityOrderByDetectedAtDesc(severity, pageable); }— returns early.if (deviceAgentId != null && !deviceAgentId.isBlank()) { return eventRepository.findByDeviceAgentIdOrderByDetectedAtDesc(...); }— UNREACHABLE when severity is non-null.src/main/java/com/hiveops/aria/repository/ThreatEventRepository.java: only single-field finders exist (findBySeverityOrderByDetectedAtDescL23,findByDeviceAgentIdOrderByDetectedAtDescL16). There is no combinedfindBySeverityAndDeviceAgentId...method.frontend/src/components/ThreatEvents.svelteL53-55: the UI sends BOTH params in the same request (severity: severityFilter || undefined, deviceAgentId: deviceSearch || undefined), and both filters can be active at once (hasActiveFilters = !!severityFilter || !!deviceSearch, L22). So the broken combination is actively reachable from the shipped UI.Impact
When an operator narrows the Threat Events view to a specific device AND a severity, the device filter is dropped: the table shows events of that severity for ALL devices while the active-filter chips still claim the device filter is applied. This presents misleading/wider-than-requested data and makes the device filter non-functional in the common combined-filter case. Not a security/scoping issue (endpoint is
hasRole('BCOS_ADMIN'), no institution scoping involved), but the feature is silently broken.Suggested fix
Add a combined repository method and route to it when both are present, e.g.:
Then in the controller:
(Or replace the manual branching with a JPA
Specification/@Querythat applies both optional predicates.)Verified against code via the guide KB verification pass.