From c91e68f31f1b5dd04da6e45f6816a67a0aa54524 Mon Sep 17 00:00:00 2001 From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com> Date: Tue, 24 Dec 2024 14:08:41 +0530 Subject: [PATCH] fix: fixed a bug --- .../com/akto/action/testing/StartTestAction.java | 8 ++++---- .../main/java/com/akto/action/testing/Utils.java | 14 ++++++++++---- .../akto/action/testing_issues/IssuesAction.java | 7 ++++--- .../web/src/apps/dashboard/pages/testing/api.js | 4 ++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java b/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java index e3a7c4ee1b..4270554599 100644 --- a/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java @@ -510,8 +510,8 @@ private List prepareTestRunResultsFilters(ObjectId testingRunResultSummary List filterList = new ArrayList<>(); filterList.add(Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, testingRunResultSummaryId)); - Bson filtersForTestingRunResults = com.akto.action.testing.Utils.createFiltersForTestingReport(filters); - filterList.add(filtersForTestingRunResults); + Bson filtersForTestingRunResults = com.akto.action.testing.Utils.createFiltersForTestingReport(reportFilterList); + if(!filtersForTestingRunResults.equals(Filters.empty())) filterList.add(filtersForTestingRunResults); if(queryMode == null) { if(fetchOnlyVulnerable) { @@ -672,7 +672,7 @@ public static void removeTestingRunResultsByIssues(List testin } } - private Map reportFilterList; + private Map> reportFilterList; public String fetchVulnerableTestRunResults() { ObjectId testingRunResultSummaryId; @@ -1377,7 +1377,7 @@ public Map getTestCountMap() { return testCountMap; } - public void setReportFilterList(Map reportFilterList) { + public void setReportFilterList(Map> reportFilterList) { this.reportFilterList = reportFilterList; } } diff --git a/apps/dashboard/src/main/java/com/akto/action/testing/Utils.java b/apps/dashboard/src/main/java/com/akto/action/testing/Utils.java index 3a8237ceec..aca9c0e0dc 100644 --- a/apps/dashboard/src/main/java/com/akto/action/testing/Utils.java +++ b/apps/dashboard/src/main/java/com/akto/action/testing/Utils.java @@ -14,13 +14,19 @@ public class Utils { - public static Bson createFiltersForTestingReport(Map filterMap){ + public static Bson createFiltersForTestingReport(Map> filterMap){ List filterList = new ArrayList<>(); - for(Map.Entry entry: filterMap.entrySet()) { + for(Map.Entry> entry: filterMap.entrySet()) { String key = entry.getKey(); - List value = entry.getValue(); + List value = entry.getValue(); if (value.isEmpty()) continue; + List collectionIds = new ArrayList<>(); + if(key.equals(SingleTypeInfo._API_COLLECTION_ID)){ + for(String str: value){ + collectionIds.add(Integer.parseInt(str)); + } + } switch (key) { case SingleTypeInfo._METHOD: @@ -28,7 +34,7 @@ public static Bson createFiltersForTestingReport(Map filterMap){ break; case SingleTypeInfo._COLLECTION_IDS: case SingleTypeInfo._API_COLLECTION_ID: - filterList.add(Filters.in(TestingRunResult.API_INFO_KEY + "." + ApiInfoKey.API_COLLECTION_ID, value)); + filterList.add(Filters.in(TestingRunResult.API_INFO_KEY + "." + ApiInfoKey.API_COLLECTION_ID, collectionIds)); break; case "categoryFilter": filterList.add(Filters.in(TestingRunResult.TEST_SUPER_TYPE, value)); diff --git a/apps/dashboard/src/main/java/com/akto/action/testing_issues/IssuesAction.java b/apps/dashboard/src/main/java/com/akto/action/testing_issues/IssuesAction.java index f1ff9206f7..883aa251ce 100644 --- a/apps/dashboard/src/main/java/com/akto/action/testing_issues/IssuesAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/testing_issues/IssuesAction.java @@ -2,6 +2,7 @@ import com.akto.action.ExportSampleDataAction; import com.akto.action.UserAction; +import com.akto.action.testing.Utils; import com.akto.dao.HistoricalDataDao; import com.akto.dao.RBACDao; import com.akto.action.testing.StartTestAction; @@ -528,7 +529,7 @@ public String bulkUpdateIssueStatus () { String latestTestingRunSummaryId; List issueStatusQuery; List testingRunResultList; - private Map filters; + private Map> filters; public String fetchIssuesByStatusAndSummaryId() { Bson triFilters = Filters.and( Filters.in(TestingRunIssues.TEST_RUN_ISSUES_STATUS, issueStatusQuery), @@ -548,7 +549,7 @@ public String fetchIssuesByStatusAndSummaryId() { List filtersList = new ArrayList<>(); if(!testingRunResultsFilterList.isEmpty()) filtersList.add(Filters.or(testingRunResultsFilterList)); - Bson filtersForTestingRunResults = com.akto.action.testing.Utils.createFiltersForTestingReport(filters); + Bson filtersForTestingRunResults = Utils.createFiltersForTestingReport(filters); if(!filtersForTestingRunResults.equals(Filters.empty())) filtersList.add(filtersForTestingRunResults); Bson sortStage = StartTestAction.prepareTestingRunResultCustomSorting(sortKey, sortOrder); @@ -854,7 +855,7 @@ public List getTestingRunResultList() { return testingRunResultList; } - public void setFilters(Map filters) { + public void setFilters(Map> filters) { this.filters = filters; } diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/api.js b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/api.js index 4dab0831c3..be973bfa69 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/api.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/testing/api.js @@ -24,12 +24,12 @@ export default { }) return resp }, - async fetchTestingRunResults(testingRunResultSummaryHexId, queryMode, sortKey, sortOrder, skip, limit, filters, queryValue) { + async fetchTestingRunResults(testingRunResultSummaryHexId, queryMode, sortKey, sortOrder, skip, limit, reportFilterList, queryValue) { const resp = await request({ url: '/api/fetchTestingRunResults', method: 'post', data: { - testingRunResultSummaryHexId, queryMode, sortKey, sortOrder, skip, limit, filters, queryValue + testingRunResultSummaryHexId, queryMode, sortKey, sortOrder, skip, limit, reportFilterList, queryValue } }) return resp