Skip to content

Commit

Permalink
Merge pull request #1890 from akto-api-security/fix/fast_report
Browse files Browse the repository at this point in the history
Making report faster
  • Loading branch information
Ark2307 authored Jan 2, 2025
2 parents 81ba0a1 + 0d8bdd2 commit a438632
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -722,46 +722,46 @@ public String fetchVulnerableTestRunResults() {
);

List<TestingRunResult> testingRunResultList = TestingRunResultDao.instance.findAll(filters, skip, 50, null);
Map<String, String> sampleDataVsCurlMap = new HashMap<>();
for (TestingRunResult runResult: testingRunResultList) {
WorkflowTest workflowTest = runResult.getWorkflowTest();
for (GenericTestResult tr : runResult.getTestResults()) {
if (tr.isVulnerable()) {
if (tr instanceof TestResult) {
TestResult testResult = (TestResult) tr;
sampleDataVsCurlMap.put(testResult.getMessage(),
ExportSampleDataAction.getCurl(testResult.getMessage()));
sampleDataVsCurlMap.put(testResult.getOriginalMessage(),
ExportSampleDataAction.getCurl(testResult.getOriginalMessage()));
} else if (tr instanceof MultiExecTestResult){
MultiExecTestResult testResult = (MultiExecTestResult) tr;
Map<String, WorkflowTestResult.NodeResult> nodeResultMap = testResult.getNodeResultMap();
for (String order : nodeResultMap.keySet()) {
WorkflowTestResult.NodeResult nodeResult = nodeResultMap.get(order);
String nodeResultLastMessage = getNodeResultLastMessage(nodeResult.getMessage());
if (nodeResultLastMessage != null) {
nodeResult.setMessage(nodeResultLastMessage);
sampleDataVsCurlMap.put(nodeResultLastMessage,
ExportSampleDataAction.getCurl(nodeResultLastMessage));
}
}
}
}
}
if (workflowTest != null) {
Map<String, WorkflowNodeDetails> nodeDetailsMap = workflowTest.getMapNodeIdToWorkflowNodeDetails();
for (String nodeName: nodeDetailsMap.keySet()) {
if (nodeDetailsMap.get(nodeName) instanceof YamlNodeDetails) {
YamlNodeDetails details = (YamlNodeDetails) nodeDetailsMap.get(nodeName);
sampleDataVsCurlMap.put(details.getOriginalMessage(),
ExportSampleDataAction.getCurl(details.getOriginalMessage()));
}

}
}
}
// Map<String, String> sampleDataVsCurlMap = new HashMap<>();
// for (TestingRunResult runResult: testingRunResultList) {
// WorkflowTest workflowTest = runResult.getWorkflowTest();
// for (GenericTestResult tr : runResult.getTestResults()) {
// if (tr.isVulnerable()) {
// if (tr instanceof TestResult) {
// TestResult testResult = (TestResult) tr;
// // sampleDataVsCurlMap.put(testResult.getMessage(),
// // ExportSampleDataAction.getCurl(testResult.getMessage()));
// // sampleDataVsCurlMap.put(testResult.getOriginalMessage(),
// // ExportSampleDataAction.getCurl(testResult.getOriginalMessage()));
// } else if (tr instanceof MultiExecTestResult){
// MultiExecTestResult testResult = (MultiExecTestResult) tr;
// Map<String, WorkflowTestResult.NodeResult> nodeResultMap = testResult.getNodeResultMap();
// for (String order : nodeResultMap.keySet()) {
// WorkflowTestResult.NodeResult nodeResult = nodeResultMap.get(order);
// String nodeResultLastMessage = getNodeResultLastMessage(nodeResult.getMessage());
// if (nodeResultLastMessage != null) {
// nodeResult.setMessage(nodeResultLastMessage);
// sampleDataVsCurlMap.put(nodeResultLastMessage,
// ExportSampleDataAction.getCurl(nodeResultLastMessage));
// }
// }
// }
// }
// }
// if (workflowTest != null) {
// Map<String, WorkflowNodeDetails> nodeDetailsMap = workflowTest.getMapNodeIdToWorkflowNodeDetails();
// for (String nodeName: nodeDetailsMap.keySet()) {
// if (nodeDetailsMap.get(nodeName) instanceof YamlNodeDetails) {
// YamlNodeDetails details = (YamlNodeDetails) nodeDetailsMap.get(nodeName);
// sampleDataVsCurlMap.put(details.getOriginalMessage(),
// ExportSampleDataAction.getCurl(details.getOriginalMessage()));
// }

// }
// }
// }
this.testingRunResults = testingRunResultList;
this.sampleDataVsCurlMap = sampleDataVsCurlMap;
// this.sampleDataVsCurlMap = sampleDataVsCurlMap;
} catch (Exception e) {
loggerMaker.errorAndAddToDb("Error while executing test run summary" + e.getMessage(), LogDb.DASHBOARD);
addActionError("Invalid test summary id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public String fetchVulnerableTestingRunResultsFromIssues() {
}
if (issues.isEmpty()) {
this.testingRunResults = new ArrayList<>();
this.sampleDataVsCurlMap = new HashMap<>();
// this.sampleDataVsCurlMap = new HashMap<>();
return SUCCESS.toUpperCase();
}
Bson orFilters = Filters.or(andFilters);
Expand All @@ -333,14 +333,14 @@ public String fetchVulnerableTestingRunResultsFromIssues() {
// todo: fix
for (TestingRunResult runResult: this.testingRunResults) {
List<GenericTestResult> testResults = new ArrayList<>();
WorkflowTest workflowTest = runResult.getWorkflowTest();
// WorkflowTest workflowTest = runResult.getWorkflowTest();
for (GenericTestResult tr : runResult.getTestResults()) {
if (tr.isVulnerable()) {
if (tr instanceof TestResult) {
TestResult testResult = (TestResult) tr;
testResults.add(testResult);
sampleDataVsCurlMap.put(testResult.getMessage(), ExportSampleDataAction.getCurl(testResult.getMessage()));
sampleDataVsCurlMap.put(testResult.getOriginalMessage(), ExportSampleDataAction.getCurl(testResult.getOriginalMessage()));
// sampleDataVsCurlMap.put(testResult.getMessage(), ExportSampleDataAction.getCurl(testResult.getMessage()));
// sampleDataVsCurlMap.put(testResult.getOriginalMessage(), ExportSampleDataAction.getCurl(testResult.getOriginalMessage()));
} else if (tr instanceof MultiExecTestResult){
MultiExecTestResult testResult = (MultiExecTestResult) tr;
testResults.add(testResult);
Expand All @@ -350,27 +350,27 @@ public String fetchVulnerableTestingRunResultsFromIssues() {
String nodeResultLastMessage = StartTestAction.getNodeResultLastMessage(nodeResult.getMessage());
if (nodeResultLastMessage != null) {
nodeResult.setMessage(nodeResultLastMessage);
sampleDataVsCurlMap.put(nodeResultLastMessage,
ExportSampleDataAction.getCurl(nodeResultLastMessage));
// sampleDataVsCurlMap.put(nodeResultLastMessage,
// ExportSampleDataAction.getCurl(nodeResultLastMessage));
}
}
}
}
if (workflowTest != null) {
Map<String, WorkflowNodeDetails> nodeDetailsMap = workflowTest.getMapNodeIdToWorkflowNodeDetails();
for (String nodeName: nodeDetailsMap.keySet()) {
if (nodeDetailsMap.get(nodeName) instanceof YamlNodeDetails) {
YamlNodeDetails details = (YamlNodeDetails) nodeDetailsMap.get(nodeName);
sampleDataVsCurlMap.put(details.getOriginalMessage(),
ExportSampleDataAction.getCurl(details.getOriginalMessage()));
}

}
}
// if (workflowTest != null) {
// Map<String, WorkflowNodeDetails> nodeDetailsMap = workflowTest.getMapNodeIdToWorkflowNodeDetails();
// for (String nodeName: nodeDetailsMap.keySet()) {
// if (nodeDetailsMap.get(nodeName) instanceof YamlNodeDetails) {
// YamlNodeDetails details = (YamlNodeDetails) nodeDetailsMap.get(nodeName);
// sampleDataVsCurlMap.put(details.getOriginalMessage(),
// ExportSampleDataAction.getCurl(details.getOriginalMessage()));
// }

// }
// }
}
runResult.setTestResults(testResults);
}
this.sampleDataVsCurlMap = sampleDataVsCurlMap;
// this.sampleDataVsCurlMap = sampleDataVsCurlMap;
} catch (Exception e) {
return ERROR.toUpperCase();
}
Expand Down

0 comments on commit a438632

Please sign in to comment.