Skip to content

Commit

Permalink
fix: fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TangoBeeAkto committed Dec 24, 2024
1 parent c3c5f84 commit c91e68f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ private List<Bson> prepareTestRunResultsFilters(ObjectId testingRunResultSummary
List<Bson> 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) {
Expand Down Expand Up @@ -672,7 +672,7 @@ public static void removeTestingRunResultsByIssues(List<TestingRunResult> testin
}
}

private Map<String, List> reportFilterList;
private Map<String, List<String>> reportFilterList;

public String fetchVulnerableTestRunResults() {
ObjectId testingRunResultSummaryId;
Expand Down Expand Up @@ -1377,7 +1377,7 @@ public Map<String, Integer> getTestCountMap() {
return testCountMap;
}

public void setReportFilterList(Map<String, List> reportFilterList) {
public void setReportFilterList(Map<String, List<String>> reportFilterList) {
this.reportFilterList = reportFilterList;
}
}
14 changes: 10 additions & 4 deletions apps/dashboard/src/main/java/com/akto/action/testing/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@

public class Utils {

public static Bson createFiltersForTestingReport(Map<String, List> filterMap){
public static Bson createFiltersForTestingReport(Map<String, List<String>> filterMap){
List<Bson> filterList = new ArrayList<>();
for(Map.Entry<String, List> entry: filterMap.entrySet()) {
for(Map.Entry<String, List<String>> entry: filterMap.entrySet()) {
String key = entry.getKey();
List value = entry.getValue();
List<String> value = entry.getValue();

if (value.isEmpty()) continue;
List<Integer> collectionIds = new ArrayList<>();
if(key.equals(SingleTypeInfo._API_COLLECTION_ID)){
for(String str: value){
collectionIds.add(Integer.parseInt(str));
}
}

switch (key) {
case SingleTypeInfo._METHOD:
filterList.add(Filters.in(TestingRunResult.API_INFO_KEY + "." + ApiInfoKey.METHOD, value));
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -528,7 +529,7 @@ public String bulkUpdateIssueStatus () {
String latestTestingRunSummaryId;
List<String> issueStatusQuery;
List<TestingRunResult> testingRunResultList;
private Map<String, List> filters;
private Map<String, List<String>> filters;
public String fetchIssuesByStatusAndSummaryId() {
Bson triFilters = Filters.and(
Filters.in(TestingRunIssues.TEST_RUN_ISSUES_STATUS, issueStatusQuery),
Expand All @@ -548,7 +549,7 @@ public String fetchIssuesByStatusAndSummaryId() {

List<Bson> 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);

Expand Down Expand Up @@ -854,7 +855,7 @@ public List<TestingRunResult> getTestingRunResultList() {
return testingRunResultList;
}

public void setFilters(Map<String, List> filters) {
public void setFilters(Map<String, List<String>> filters) {
this.filters = filters;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c91e68f

Please sign in to comment.