if (!PermissionUtils.isAuthorized(Permission.READ_ACCESS, orgId, appId)) {
return writer.writeValueAsString(RestResponse.failure("You are not authorized to view this information."));
}
Application application = applicationService.loadApplication(appId);
if (application == null || !application.isActive()) {
log.warn(ResourceNotFoundException.getLogMessage("Application", appId));
throw new ResourceNotFoundException();
}
long numClosedVulns = applicationService.getVulnCount(appId, false);
long numVulns = applicationService.getCount(appId, bean);
TableSortBean falsePositiveBean = new TableSortBean();
falsePositiveBean.setFalsePositive(true);
long falsePositiveCount = applicationService.getCount(appId, falsePositiveBean);
TableSortBean hiddenBean = new TableSortBean();
hiddenBean.setHidden(true);
long numHiddenVulns = applicationService.getCount(appId, hiddenBean);
TableSortBean openBean = new TableSortBean();
openBean.setOpen(true);
long numOpenVulns = applicationService.getCount(appId, openBean);
long numPages = numVulns / 100;
if (numVulns % 100 == 0) {
numPages -= 1;
}
if (bean.getPage() > numPages) {
bean.setPage((int) (numPages + 1));
}
if (bean.getPage() < 1) {
bean.setPage(1);
}
List<Vulnerability> vulnList = applicationService.getVulnTable(appId, bean);
Map<String, Object> responseMap = new HashMap<>();
responseMap.put("vulnerabilities", vulnList);
responseMap.put("numVulns", numVulns);
responseMap.put("numClosed", numClosedVulns);
responseMap.put("numHidden", numHiddenVulns);
responseMap.put("numOpen", numOpenVulns);
responseMap.put("numFalsePositive", falsePositiveCount);
responseMap.put("genericVulnerabilities", genericVulnerabilityService.loadAll());
responseMap.put("scans", application.getScans());
log.info("Took " + (System.currentTimeMillis() - start) + " ms to generate map objects.");
return writer.writeValueAsString(RestResponse.success(responseMap));
}