diff --git a/apps/dashboard/src/main/java/com/akto/action/threat_detection/SuspectSampleDataAction.java b/apps/dashboard/src/main/java/com/akto/action/threat_detection/SuspectSampleDataAction.java index c4aa7600a5..35d8678b05 100644 --- a/apps/dashboard/src/main/java/com/akto/action/threat_detection/SuspectSampleDataAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/threat_detection/SuspectSampleDataAction.java @@ -42,20 +42,39 @@ public SuspectSampleDataAction() { } public String fetchSampleData() { - HttpPost post = - new HttpPost( - String.format("%s/api/dashboard/list_malicious_requests", this.getBackendUrl())); + HttpPost post = new HttpPost( + String.format("%s/api/dashboard/list_malicious_requests", this.getBackendUrl())); post.addHeader("Authorization", "Bearer " + this.getApiToken()); post.addHeader("Content-Type", "application/json"); - Map body = - new HashMap() { - { - put("skip", skip); - put("limit", LIMIT); - put("sort", sort); - } - }; + Map filter = new HashMap<>(); + if (this.ips != null && !this.ips.isEmpty()) { + filter.put("ips", this.ips); + } + + if (this.urls != null && !this.urls.isEmpty()) { + filter.put("urls", this.urls); + } + + Map time_range = new HashMap<>(); + if (this.startTimestamp > 0) { + time_range.put("start", this.startTimestamp); + } + + if (this.endTimestamp > 0) { + time_range.put("end", this.endTimestamp); + } + + filter.put("detected_at_time_range", time_range); + + Map body = new HashMap() { + { + put("skip", skip); + put("limit", LIMIT); + put("sort", sort); + put("filter", filter); + } + }; String msg = objectMapper.valueToTree(body).toString(); StringEntity requestEntity = new StringEntity(msg, ContentType.APPLICATION_JSON); @@ -65,24 +84,22 @@ public String fetchSampleData() { String responseBody = EntityUtils.toString(resp.getEntity()); ProtoMessageUtils.toProtoMessage( - ListMaliciousRequestsResponse.class, responseBody) + ListMaliciousRequestsResponse.class, responseBody) .ifPresent( m -> { - this.maliciousEvents = - m.getMaliciousEventsList().stream() - .map( - smr -> - new DashboardMaliciousEvent( - smr.getId(), - smr.getActor(), - smr.getFilterId(), - smr.getEndpoint(), - URLMethods.Method.fromString(smr.getMethod()), - smr.getApiCollectionId(), - smr.getIp(), - smr.getCountry(), - smr.getDetectedAt())) - .collect(Collectors.toList()); + this.maliciousEvents = m.getMaliciousEventsList().stream() + .map( + smr -> new DashboardMaliciousEvent( + smr.getId(), + smr.getActor(), + smr.getFilterId(), + smr.getEndpoint(), + URLMethods.Method.fromString(smr.getMethod()), + smr.getApiCollectionId(), + smr.getIp(), + smr.getCountry(), + smr.getDetectedAt())) + .collect(Collectors.toList()); this.total = m.getTotal(); }); } catch (Exception e) { @@ -94,8 +111,7 @@ public String fetchSampleData() { } public String fetchFilters() { - HttpGet get = - new HttpGet(String.format("%s/api/dashboard/fetch_filters", this.getBackendUrl())); + HttpGet get = new HttpGet(String.format("%s/api/dashboard/fetch_filters", this.getBackendUrl())); get.addHeader("Authorization", "Bearer " + this.getApiToken()); get.addHeader("Content-Type", "application/json"); @@ -103,7 +119,7 @@ public String fetchFilters() { String responseBody = EntityUtils.toString(resp.getEntity()); ProtoMessageUtils.toProtoMessage( - FetchAlertFiltersResponse.class, responseBody) + FetchAlertFiltersResponse.class, responseBody) .ifPresent( msg -> { this.ips = msg.getActorsList(); diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/threat_detection/components/SusDataTable.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/threat_detection/components/SusDataTable.jsx index 24c8d8387a..8b1755786f 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/threat_detection/components/SusDataTable.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/threat_detection/components/SusDataTable.jsx @@ -149,12 +149,6 @@ function SusDataTable({ currDateRange, rowClicked }) { }); filters = [ - { - key: "apiCollectionId", - label: "Collection", - title: "Collection", - choices: apiCollectionFilterChoices, - }, { key: "sourceIps", label: "Source IP",