@Test public void getVulnerabilitySummaryTest() throws Exception { ReflectionTestUtils.setField(vulnerabilityService, "vulnTypes", "test"); assertThat(vulnerabilityService.getVulnerabilitySummary("ag", "3,4,5"), is(notNullValue())); ReflectionTestUtils.setField(vulnerabilityService, "vulnTypes", "ec2"); when(vulnerabilityRepository.getUniqueHost(anyString(), anyString())).thenReturn(new HashMap<String, Object>()); when(vulnerabilityRepository.getVulnInfo(anyString(), anyString())).thenReturn(new HashMap<String, Object>()); when(vulnerabilityRepository.getUniqueApp(anyString())).thenReturn(new HashMap<String, Object>()); AssetCount totalAssets = new AssetCount(); AssetCountData data = new AssetCountData(); AssetCountByAppEnvDTO assetCount_Count = new AssetCountByAppEnvDTO(); assetCount_Count.setType("onpremserver"); assetCount_Count.setCount("1"); List<AssetCountByAppEnvDTO> assetAppEnvDTOs = new ArrayList<AssetCountByAppEnvDTO>(); assetAppEnvDTOs.add(assetCount_Count); data.setAssetcount(assetAppEnvDTOs.toArray(new AssetCountByAppEnvDTO[assetAppEnvDTOs.size()])); totalAssets.setData(data); List<LinkedHashMap<String, Object>> response = new ArrayList<>(); LinkedHashMap<String, Object> obj = new LinkedHashMap<>(); obj.put("assetsScanned", 5); obj.put("failed", 2); obj.put("passed", 2); response.add(obj); Map<String, Object> responseMap = new HashMap<>(); responseMap.put("response", response); ResponseEntity<Object> nonCompliancePolicyRuleresponse = ResponseUtils.buildSucessResponse(responseMap); when(complianceServiceClient.getNonCompliancePolicyByRule(any(Request.class))) .thenReturn(nonCompliancePolicyRuleresponse); when(vulnerabilityRepository.getTotalQualysHostCount(anyString(), anyString())).thenReturn(1L); ReflectionTestUtils.setField(vulnerabilityService, "vulnSummarySeverity", "3"); Map<String, Object> vulnSummary = new HashMap<>(); List<Map<String, Object>> severityInfo = new ArrayList<>(); Map<String, Object> severity = new HashMap<>(); severity.put(Constants.SEVEITY_LEVEL, 3); severity.put(Constants.COUNT, 2); severity.put(Constants.VULN_COUNT, 2); severityInfo.add(severity); severity = new HashMap<>(); severity.put(Constants.SEVEITY_LEVEL, 4); severity.put(Constants.COUNT, 2); severity.put(Constants.VULN_COUNT, 2); severityInfo.add(severity); severity = new HashMap<>(); severity.put(Constants.SEVEITY_LEVEL, 5); severity.put(Constants.COUNT, 2); severity.put(Constants.VULN_COUNT, 2); severityInfo.add(severity); vulnSummary.put("severityInfo", severityInfo); assertThat(vulnerabilityService.getVulnerabilitySummary("ag", "3,4,5"), is(notNullValue())); Map<String, Object> uniqueHost = new HashMap<>(); uniqueHost.put("total", 10); uniqueHost.put("3", 1); Map<String, Object> vulnInfo = new HashMap<>(); Map<String, Object> vulnInfoMap = new HashMap<>(); vulnInfoMap.put(Constants.VULN_COUNT, 2); vulnInfoMap.put(Constants.UNIQUE_VULN_COUNT, 2); vulnInfo.put("total", 10); vulnInfo.put("3", vulnInfoMap); Map<String, Object> uniqueApp = new HashMap<>(); uniqueApp.put("3", 1); ReflectionTestUtils.setField(vulnerabilityService, "vulnTypes", "ec2,onpremserver"); when(vulnerabilityRepository.getUniqueHost(anyString(), anyString())).thenReturn(uniqueHost); when(vulnerabilityRepository.getVulnInfo(anyString(), anyString())).thenReturn(vulnInfo); when(vulnerabilityRepository.getUniqueApp(anyString())).thenReturn(uniqueApp); when(complianceServiceClient.getNonCompliancePolicyByRule(any(Request.class))) .thenReturn(nonCompliancePolicyRuleresponse); when(assetServiceClient.getTotalAssetsCount(anyString(), anyString(), anyString())).thenReturn(totalAssets); when(vulnerabilityRepository.getTotalQualysHostCount(anyString(), anyString())).thenReturn(1L); ReflectionTestUtils.setField(vulnerabilityService, "vulnSummarySeverity", "3"); vulnSummary.put("severityInfo", severityInfo); assertThat(vulnerabilityService.getVulnerabilitySummary("ag", "3"), is(notNullValue())); }
@SuppressWarnings({ "unchecked" }) public Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity) throws ServiceException { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); Map<String, Object> vulnerabilitySummary = new HashMap<>(); List<Map<String, Object>> severityInfo = new ArrayList<>(); if (vulnTargetTypes.isEmpty()) { for (int i = 3; i <= 5; i++) { Map<String, Object> sevInfo = new HashMap<>(); sevInfo.put(SEVERITY, "S" + i); sevInfo.put(SEVEITY_LEVEL, i); sevInfo.put(COUNT, 0); sevInfo.put("appCount", 0); sevInfo.put("hostCount", 0); sevInfo.put(UNIQUE_VULN_COUNT, 0); sevInfo.put(VULN_COUNT, 0); severityInfo.add(sevInfo); } vulnerabilitySummary.put(SEV_INFO, severityInfo); vulnerabilitySummary.put(VULNEREBILITIES, 0); vulnerabilitySummary.put("hosts", 0); vulnerabilitySummary.put(TOTAL_VULN_ASSETS, 0); vulnerabilitySummary.put("compliantpercent", 100); vulnerabilitySummary.put("assetsWithVulns", 0); return vulnerabilitySummary; } else { Map<String, Map<String, Object>> queryResults = new HashMap<>(); long totalQualysCount = 0; long vulnerableAssetCount = 0; long totalAssetCount = 0; ExecutorService executor = Executors.newFixedThreadPool(3); executor.execute(() -> { queryResults.put("uniqueHost", vulnerabilityRepository.getUniqueHost(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("VulnInfo", vulnerabilityRepository.getVulnInfo(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("uniqueApp", vulnerabilityRepository.getUniqueApp(assetGroup)); }); executor.shutdown(); while (!executor.isTerminated()) { } Map<String, Object> uniqueHost = queryResults.get("uniqueHost"); Map<String, Object> vulnInfo = queryResults.get("VulnInfo"); Map<String, Object> uniqueApp = queryResults.get("uniqueApp"); List<String> sevList = Arrays.asList(reqSeverity.split(",")); List<String> summarySevList = Arrays.asList(vulnSummarySeverity.split(",")); Map<String, Object> sevVulnInfo; Map<String, Object> vulnInfoMap; List<Map<String, Object>> sevVulnfoList = new ArrayList<>(); vulnerabilitySummary.put(SEV_INFO, sevVulnfoList); for (String sev : sevList) { sevVulnInfo = new HashMap<>(); sevVulnInfo.put(SEVEITY_LEVEL, Integer.valueOf(sev)); sevVulnInfo.put(SEVERITY, "S" + sev); sevVulnInfo.put("hostCount", uniqueHost.get(sev) == null ? 0 : uniqueHost.get(sev)); if (summarySevList.contains(sev)) { vulnerableAssetCount += Long.valueOf(sevVulnInfo.get("hostCount").toString()); } vulnInfoMap = (Map<String, Object>) vulnInfo.get(sev); if (vulnInfoMap != null) { sevVulnInfo.put(COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(VULN_COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(UNIQUE_VULN_COUNT, vulnInfoMap.get(UNIQUE_VULN_COUNT)); } else { sevVulnInfo.put(COUNT, 0); sevVulnInfo.put(VULN_COUNT, 0); sevVulnInfo.put(UNIQUE_VULN_COUNT, 0); } sevVulnInfo.put("appCount", uniqueApp.get(sev) == null ? 0 : uniqueApp.get(sev)); sevVulnfoList.add(sevVulnInfo); } vulnerabilitySummary.put(UNIQUE_VULN_COUNT, sevVulnfoList.stream() .mapToLong(sevData -> Long.valueOf(sevData.get(UNIQUE_VULN_COUNT).toString())).sum()); vulnerabilitySummary.put("assetsWithVulns", uniqueHost.get(TOTAL) == null ? 0 : uniqueHost.get(TOTAL)); vulnerabilitySummary.put(VULNEREBILITIES, vulnInfo.get(TOTAL) == null ? 0 : vulnInfo.get(TOTAL)); if (sevList.stream().filter(summarySevList::contains).count() != summarySevList.size()) { vulnerableAssetCount = Long.valueOf( vulnerabilityRepository.getUniqueHost(assetGroup, vulnSummarySeverity).get(TOTAL).toString()); } for (String vulnType : vulnTargetTypes) { try { if (vulnType.equals(ONPREMSERVER)) { AssetCount totalAssets = assetServiceClient.getTotalAssetsCount(assetGroup, vulnType, null); AssetCountData data = totalAssets.getData(); AssetCountByAppEnvDTO[] assetcount = data.getAssetcount(); Long totalAssetsCount = 0l; for (AssetCountByAppEnvDTO assetCount_Count : assetcount) { if (assetCount_Count.getType().equalsIgnoreCase(vulnType)) { totalAssetsCount = Long.parseLong(assetCount_Count.getCount()); } } totalAssetCount += totalAssetsCount; totalQualysCount += vulnerabilityRepository.getTotalQualysHostCount(assetGroup, vulnType); } else { Request request = new Request(); request.setAg(assetGroup); Map<String, String> filter = new HashMap<>(); filter.put("domain", "Infra & Platforms"); if (vulnType.equals(EC2)) { filter.put("ruleId.keyword", EC2_QUALYS_RULEID); } if (vulnType.equals(VIRTUALMACHINE)) { filter.put("ruleId.keyword", VIRTUALMACHINE_QUALYS_RULEID); } request.setFilter(filter); List<LinkedHashMap<String, Object>> responses = new ArrayList<>(); Map<String, Object> response = new HashMap<>(); ResponseEntity<Object> nonCompliancePolicyRuleresponse = complianceServiceClient .getNonCompliancePolicyByRule(request); if (nonCompliancePolicyRuleresponse != null) { Map<String, Object> responseBody = (Map<String, Object>) nonCompliancePolicyRuleresponse .getBody(); Map<String, Object> dataResponseMap = (Map<String, Object>) responseBody.get("data"); responses = (List<LinkedHashMap<String, Object>>) dataResponseMap.get("response"); if (responses.size() > 0) { response = responses.get(0); totalAssetCount += Long.valueOf(response.get("assetsScanned").toString()); totalQualysCount += Long.valueOf(response.get("passed").toString()); } } } } catch (DataException e) { throw new ServiceException(); } } try { vulnerabilitySummary.put("hosts", totalAssetCount); if (totalQualysCount > totalAssetCount) { totalQualysCount = totalAssetCount; } long totalVulnerableAssets = totalAssetCount - totalQualysCount + vulnerableAssetCount; if (totalVulnerableAssets > totalAssetCount) { totalVulnerableAssets = totalAssetCount; } vulnerabilitySummary.put(TOTAL_VULN_ASSETS, totalVulnerableAssets); float compliantCount = (float) totalAssetCount - totalVulnerableAssets; float compliantpercent = 100; if (totalAssetCount > 0) { compliantpercent = (compliantCount / totalAssetCount) * 100; } DecimalFormat df = new DecimalFormat("#.00"); vulnerabilitySummary.put("compliantpercent", Math.floor(Float.valueOf(df.format(compliantpercent)))); vulnerabilitySummary.put("hostsScanned", totalQualysCount); vulnerabilitySummary.put("hostsNotScanned", totalAssetCount - totalQualysCount); if (totalAssetCount > 0) { vulnerabilitySummary.put("hostsScanCoverage", Math.floor((1.0 * totalQualysCount / totalAssetCount) * 100)); } else { vulnerabilitySummary.put("hostsScanCoverage", 0); } } catch (Exception e) { logger.error(e); throw new ServiceException(e); } if (vulnerabilitySummary.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return vulnerabilitySummary; } }
VulnerabilityService implements Constants { @SuppressWarnings({ "unchecked" }) public Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity) throws ServiceException { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); Map<String, Object> vulnerabilitySummary = new HashMap<>(); List<Map<String, Object>> severityInfo = new ArrayList<>(); if (vulnTargetTypes.isEmpty()) { for (int i = 3; i <= 5; i++) { Map<String, Object> sevInfo = new HashMap<>(); sevInfo.put(SEVERITY, "S" + i); sevInfo.put(SEVEITY_LEVEL, i); sevInfo.put(COUNT, 0); sevInfo.put("appCount", 0); sevInfo.put("hostCount", 0); sevInfo.put(UNIQUE_VULN_COUNT, 0); sevInfo.put(VULN_COUNT, 0); severityInfo.add(sevInfo); } vulnerabilitySummary.put(SEV_INFO, severityInfo); vulnerabilitySummary.put(VULNEREBILITIES, 0); vulnerabilitySummary.put("hosts", 0); vulnerabilitySummary.put(TOTAL_VULN_ASSETS, 0); vulnerabilitySummary.put("compliantpercent", 100); vulnerabilitySummary.put("assetsWithVulns", 0); return vulnerabilitySummary; } else { Map<String, Map<String, Object>> queryResults = new HashMap<>(); long totalQualysCount = 0; long vulnerableAssetCount = 0; long totalAssetCount = 0; ExecutorService executor = Executors.newFixedThreadPool(3); executor.execute(() -> { queryResults.put("uniqueHost", vulnerabilityRepository.getUniqueHost(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("VulnInfo", vulnerabilityRepository.getVulnInfo(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("uniqueApp", vulnerabilityRepository.getUniqueApp(assetGroup)); }); executor.shutdown(); while (!executor.isTerminated()) { } Map<String, Object> uniqueHost = queryResults.get("uniqueHost"); Map<String, Object> vulnInfo = queryResults.get("VulnInfo"); Map<String, Object> uniqueApp = queryResults.get("uniqueApp"); List<String> sevList = Arrays.asList(reqSeverity.split(",")); List<String> summarySevList = Arrays.asList(vulnSummarySeverity.split(",")); Map<String, Object> sevVulnInfo; Map<String, Object> vulnInfoMap; List<Map<String, Object>> sevVulnfoList = new ArrayList<>(); vulnerabilitySummary.put(SEV_INFO, sevVulnfoList); for (String sev : sevList) { sevVulnInfo = new HashMap<>(); sevVulnInfo.put(SEVEITY_LEVEL, Integer.valueOf(sev)); sevVulnInfo.put(SEVERITY, "S" + sev); sevVulnInfo.put("hostCount", uniqueHost.get(sev) == null ? 0 : uniqueHost.get(sev)); if (summarySevList.contains(sev)) { vulnerableAssetCount += Long.valueOf(sevVulnInfo.get("hostCount").toString()); } vulnInfoMap = (Map<String, Object>) vulnInfo.get(sev); if (vulnInfoMap != null) { sevVulnInfo.put(COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(VULN_COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(UNIQUE_VULN_COUNT, vulnInfoMap.get(UNIQUE_VULN_COUNT)); } else { sevVulnInfo.put(COUNT, 0); sevVulnInfo.put(VULN_COUNT, 0); sevVulnInfo.put(UNIQUE_VULN_COUNT, 0); } sevVulnInfo.put("appCount", uniqueApp.get(sev) == null ? 0 : uniqueApp.get(sev)); sevVulnfoList.add(sevVulnInfo); } vulnerabilitySummary.put(UNIQUE_VULN_COUNT, sevVulnfoList.stream() .mapToLong(sevData -> Long.valueOf(sevData.get(UNIQUE_VULN_COUNT).toString())).sum()); vulnerabilitySummary.put("assetsWithVulns", uniqueHost.get(TOTAL) == null ? 0 : uniqueHost.get(TOTAL)); vulnerabilitySummary.put(VULNEREBILITIES, vulnInfo.get(TOTAL) == null ? 0 : vulnInfo.get(TOTAL)); if (sevList.stream().filter(summarySevList::contains).count() != summarySevList.size()) { vulnerableAssetCount = Long.valueOf( vulnerabilityRepository.getUniqueHost(assetGroup, vulnSummarySeverity).get(TOTAL).toString()); } for (String vulnType : vulnTargetTypes) { try { if (vulnType.equals(ONPREMSERVER)) { AssetCount totalAssets = assetServiceClient.getTotalAssetsCount(assetGroup, vulnType, null); AssetCountData data = totalAssets.getData(); AssetCountByAppEnvDTO[] assetcount = data.getAssetcount(); Long totalAssetsCount = 0l; for (AssetCountByAppEnvDTO assetCount_Count : assetcount) { if (assetCount_Count.getType().equalsIgnoreCase(vulnType)) { totalAssetsCount = Long.parseLong(assetCount_Count.getCount()); } } totalAssetCount += totalAssetsCount; totalQualysCount += vulnerabilityRepository.getTotalQualysHostCount(assetGroup, vulnType); } else { Request request = new Request(); request.setAg(assetGroup); Map<String, String> filter = new HashMap<>(); filter.put("domain", "Infra & Platforms"); if (vulnType.equals(EC2)) { filter.put("ruleId.keyword", EC2_QUALYS_RULEID); } if (vulnType.equals(VIRTUALMACHINE)) { filter.put("ruleId.keyword", VIRTUALMACHINE_QUALYS_RULEID); } request.setFilter(filter); List<LinkedHashMap<String, Object>> responses = new ArrayList<>(); Map<String, Object> response = new HashMap<>(); ResponseEntity<Object> nonCompliancePolicyRuleresponse = complianceServiceClient .getNonCompliancePolicyByRule(request); if (nonCompliancePolicyRuleresponse != null) { Map<String, Object> responseBody = (Map<String, Object>) nonCompliancePolicyRuleresponse .getBody(); Map<String, Object> dataResponseMap = (Map<String, Object>) responseBody.get("data"); responses = (List<LinkedHashMap<String, Object>>) dataResponseMap.get("response"); if (responses.size() > 0) { response = responses.get(0); totalAssetCount += Long.valueOf(response.get("assetsScanned").toString()); totalQualysCount += Long.valueOf(response.get("passed").toString()); } } } } catch (DataException e) { throw new ServiceException(); } } try { vulnerabilitySummary.put("hosts", totalAssetCount); if (totalQualysCount > totalAssetCount) { totalQualysCount = totalAssetCount; } long totalVulnerableAssets = totalAssetCount - totalQualysCount + vulnerableAssetCount; if (totalVulnerableAssets > totalAssetCount) { totalVulnerableAssets = totalAssetCount; } vulnerabilitySummary.put(TOTAL_VULN_ASSETS, totalVulnerableAssets); float compliantCount = (float) totalAssetCount - totalVulnerableAssets; float compliantpercent = 100; if (totalAssetCount > 0) { compliantpercent = (compliantCount / totalAssetCount) * 100; } DecimalFormat df = new DecimalFormat("#.00"); vulnerabilitySummary.put("compliantpercent", Math.floor(Float.valueOf(df.format(compliantpercent)))); vulnerabilitySummary.put("hostsScanned", totalQualysCount); vulnerabilitySummary.put("hostsNotScanned", totalAssetCount - totalQualysCount); if (totalAssetCount > 0) { vulnerabilitySummary.put("hostsScanCoverage", Math.floor((1.0 * totalQualysCount / totalAssetCount) * 100)); } else { vulnerabilitySummary.put("hostsScanCoverage", 0); } } catch (Exception e) { logger.error(e); throw new ServiceException(e); } if (vulnerabilitySummary.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return vulnerabilitySummary; } } }
VulnerabilityService implements Constants { @SuppressWarnings({ "unchecked" }) public Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity) throws ServiceException { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); Map<String, Object> vulnerabilitySummary = new HashMap<>(); List<Map<String, Object>> severityInfo = new ArrayList<>(); if (vulnTargetTypes.isEmpty()) { for (int i = 3; i <= 5; i++) { Map<String, Object> sevInfo = new HashMap<>(); sevInfo.put(SEVERITY, "S" + i); sevInfo.put(SEVEITY_LEVEL, i); sevInfo.put(COUNT, 0); sevInfo.put("appCount", 0); sevInfo.put("hostCount", 0); sevInfo.put(UNIQUE_VULN_COUNT, 0); sevInfo.put(VULN_COUNT, 0); severityInfo.add(sevInfo); } vulnerabilitySummary.put(SEV_INFO, severityInfo); vulnerabilitySummary.put(VULNEREBILITIES, 0); vulnerabilitySummary.put("hosts", 0); vulnerabilitySummary.put(TOTAL_VULN_ASSETS, 0); vulnerabilitySummary.put("compliantpercent", 100); vulnerabilitySummary.put("assetsWithVulns", 0); return vulnerabilitySummary; } else { Map<String, Map<String, Object>> queryResults = new HashMap<>(); long totalQualysCount = 0; long vulnerableAssetCount = 0; long totalAssetCount = 0; ExecutorService executor = Executors.newFixedThreadPool(3); executor.execute(() -> { queryResults.put("uniqueHost", vulnerabilityRepository.getUniqueHost(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("VulnInfo", vulnerabilityRepository.getVulnInfo(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("uniqueApp", vulnerabilityRepository.getUniqueApp(assetGroup)); }); executor.shutdown(); while (!executor.isTerminated()) { } Map<String, Object> uniqueHost = queryResults.get("uniqueHost"); Map<String, Object> vulnInfo = queryResults.get("VulnInfo"); Map<String, Object> uniqueApp = queryResults.get("uniqueApp"); List<String> sevList = Arrays.asList(reqSeverity.split(",")); List<String> summarySevList = Arrays.asList(vulnSummarySeverity.split(",")); Map<String, Object> sevVulnInfo; Map<String, Object> vulnInfoMap; List<Map<String, Object>> sevVulnfoList = new ArrayList<>(); vulnerabilitySummary.put(SEV_INFO, sevVulnfoList); for (String sev : sevList) { sevVulnInfo = new HashMap<>(); sevVulnInfo.put(SEVEITY_LEVEL, Integer.valueOf(sev)); sevVulnInfo.put(SEVERITY, "S" + sev); sevVulnInfo.put("hostCount", uniqueHost.get(sev) == null ? 0 : uniqueHost.get(sev)); if (summarySevList.contains(sev)) { vulnerableAssetCount += Long.valueOf(sevVulnInfo.get("hostCount").toString()); } vulnInfoMap = (Map<String, Object>) vulnInfo.get(sev); if (vulnInfoMap != null) { sevVulnInfo.put(COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(VULN_COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(UNIQUE_VULN_COUNT, vulnInfoMap.get(UNIQUE_VULN_COUNT)); } else { sevVulnInfo.put(COUNT, 0); sevVulnInfo.put(VULN_COUNT, 0); sevVulnInfo.put(UNIQUE_VULN_COUNT, 0); } sevVulnInfo.put("appCount", uniqueApp.get(sev) == null ? 0 : uniqueApp.get(sev)); sevVulnfoList.add(sevVulnInfo); } vulnerabilitySummary.put(UNIQUE_VULN_COUNT, sevVulnfoList.stream() .mapToLong(sevData -> Long.valueOf(sevData.get(UNIQUE_VULN_COUNT).toString())).sum()); vulnerabilitySummary.put("assetsWithVulns", uniqueHost.get(TOTAL) == null ? 0 : uniqueHost.get(TOTAL)); vulnerabilitySummary.put(VULNEREBILITIES, vulnInfo.get(TOTAL) == null ? 0 : vulnInfo.get(TOTAL)); if (sevList.stream().filter(summarySevList::contains).count() != summarySevList.size()) { vulnerableAssetCount = Long.valueOf( vulnerabilityRepository.getUniqueHost(assetGroup, vulnSummarySeverity).get(TOTAL).toString()); } for (String vulnType : vulnTargetTypes) { try { if (vulnType.equals(ONPREMSERVER)) { AssetCount totalAssets = assetServiceClient.getTotalAssetsCount(assetGroup, vulnType, null); AssetCountData data = totalAssets.getData(); AssetCountByAppEnvDTO[] assetcount = data.getAssetcount(); Long totalAssetsCount = 0l; for (AssetCountByAppEnvDTO assetCount_Count : assetcount) { if (assetCount_Count.getType().equalsIgnoreCase(vulnType)) { totalAssetsCount = Long.parseLong(assetCount_Count.getCount()); } } totalAssetCount += totalAssetsCount; totalQualysCount += vulnerabilityRepository.getTotalQualysHostCount(assetGroup, vulnType); } else { Request request = new Request(); request.setAg(assetGroup); Map<String, String> filter = new HashMap<>(); filter.put("domain", "Infra & Platforms"); if (vulnType.equals(EC2)) { filter.put("ruleId.keyword", EC2_QUALYS_RULEID); } if (vulnType.equals(VIRTUALMACHINE)) { filter.put("ruleId.keyword", VIRTUALMACHINE_QUALYS_RULEID); } request.setFilter(filter); List<LinkedHashMap<String, Object>> responses = new ArrayList<>(); Map<String, Object> response = new HashMap<>(); ResponseEntity<Object> nonCompliancePolicyRuleresponse = complianceServiceClient .getNonCompliancePolicyByRule(request); if (nonCompliancePolicyRuleresponse != null) { Map<String, Object> responseBody = (Map<String, Object>) nonCompliancePolicyRuleresponse .getBody(); Map<String, Object> dataResponseMap = (Map<String, Object>) responseBody.get("data"); responses = (List<LinkedHashMap<String, Object>>) dataResponseMap.get("response"); if (responses.size() > 0) { response = responses.get(0); totalAssetCount += Long.valueOf(response.get("assetsScanned").toString()); totalQualysCount += Long.valueOf(response.get("passed").toString()); } } } } catch (DataException e) { throw new ServiceException(); } } try { vulnerabilitySummary.put("hosts", totalAssetCount); if (totalQualysCount > totalAssetCount) { totalQualysCount = totalAssetCount; } long totalVulnerableAssets = totalAssetCount - totalQualysCount + vulnerableAssetCount; if (totalVulnerableAssets > totalAssetCount) { totalVulnerableAssets = totalAssetCount; } vulnerabilitySummary.put(TOTAL_VULN_ASSETS, totalVulnerableAssets); float compliantCount = (float) totalAssetCount - totalVulnerableAssets; float compliantpercent = 100; if (totalAssetCount > 0) { compliantpercent = (compliantCount / totalAssetCount) * 100; } DecimalFormat df = new DecimalFormat("#.00"); vulnerabilitySummary.put("compliantpercent", Math.floor(Float.valueOf(df.format(compliantpercent)))); vulnerabilitySummary.put("hostsScanned", totalQualysCount); vulnerabilitySummary.put("hostsNotScanned", totalAssetCount - totalQualysCount); if (totalAssetCount > 0) { vulnerabilitySummary.put("hostsScanCoverage", Math.floor((1.0 * totalQualysCount / totalAssetCount) * 100)); } else { vulnerabilitySummary.put("hostsScanCoverage", 0); } } catch (Exception e) { logger.error(e); throw new ServiceException(e); } if (vulnerabilitySummary.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return vulnerabilitySummary; } }  }
VulnerabilityService implements Constants { @SuppressWarnings({ "unchecked" }) public Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity) throws ServiceException { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); Map<String, Object> vulnerabilitySummary = new HashMap<>(); List<Map<String, Object>> severityInfo = new ArrayList<>(); if (vulnTargetTypes.isEmpty()) { for (int i = 3; i <= 5; i++) { Map<String, Object> sevInfo = new HashMap<>(); sevInfo.put(SEVERITY, "S" + i); sevInfo.put(SEVEITY_LEVEL, i); sevInfo.put(COUNT, 0); sevInfo.put("appCount", 0); sevInfo.put("hostCount", 0); sevInfo.put(UNIQUE_VULN_COUNT, 0); sevInfo.put(VULN_COUNT, 0); severityInfo.add(sevInfo); } vulnerabilitySummary.put(SEV_INFO, severityInfo); vulnerabilitySummary.put(VULNEREBILITIES, 0); vulnerabilitySummary.put("hosts", 0); vulnerabilitySummary.put(TOTAL_VULN_ASSETS, 0); vulnerabilitySummary.put("compliantpercent", 100); vulnerabilitySummary.put("assetsWithVulns", 0); return vulnerabilitySummary; } else { Map<String, Map<String, Object>> queryResults = new HashMap<>(); long totalQualysCount = 0; long vulnerableAssetCount = 0; long totalAssetCount = 0; ExecutorService executor = Executors.newFixedThreadPool(3); executor.execute(() -> { queryResults.put("uniqueHost", vulnerabilityRepository.getUniqueHost(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("VulnInfo", vulnerabilityRepository.getVulnInfo(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("uniqueApp", vulnerabilityRepository.getUniqueApp(assetGroup)); }); executor.shutdown(); while (!executor.isTerminated()) { } Map<String, Object> uniqueHost = queryResults.get("uniqueHost"); Map<String, Object> vulnInfo = queryResults.get("VulnInfo"); Map<String, Object> uniqueApp = queryResults.get("uniqueApp"); List<String> sevList = Arrays.asList(reqSeverity.split(",")); List<String> summarySevList = Arrays.asList(vulnSummarySeverity.split(",")); Map<String, Object> sevVulnInfo; Map<String, Object> vulnInfoMap; List<Map<String, Object>> sevVulnfoList = new ArrayList<>(); vulnerabilitySummary.put(SEV_INFO, sevVulnfoList); for (String sev : sevList) { sevVulnInfo = new HashMap<>(); sevVulnInfo.put(SEVEITY_LEVEL, Integer.valueOf(sev)); sevVulnInfo.put(SEVERITY, "S" + sev); sevVulnInfo.put("hostCount", uniqueHost.get(sev) == null ? 0 : uniqueHost.get(sev)); if (summarySevList.contains(sev)) { vulnerableAssetCount += Long.valueOf(sevVulnInfo.get("hostCount").toString()); } vulnInfoMap = (Map<String, Object>) vulnInfo.get(sev); if (vulnInfoMap != null) { sevVulnInfo.put(COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(VULN_COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(UNIQUE_VULN_COUNT, vulnInfoMap.get(UNIQUE_VULN_COUNT)); } else { sevVulnInfo.put(COUNT, 0); sevVulnInfo.put(VULN_COUNT, 0); sevVulnInfo.put(UNIQUE_VULN_COUNT, 0); } sevVulnInfo.put("appCount", uniqueApp.get(sev) == null ? 0 : uniqueApp.get(sev)); sevVulnfoList.add(sevVulnInfo); } vulnerabilitySummary.put(UNIQUE_VULN_COUNT, sevVulnfoList.stream() .mapToLong(sevData -> Long.valueOf(sevData.get(UNIQUE_VULN_COUNT).toString())).sum()); vulnerabilitySummary.put("assetsWithVulns", uniqueHost.get(TOTAL) == null ? 0 : uniqueHost.get(TOTAL)); vulnerabilitySummary.put(VULNEREBILITIES, vulnInfo.get(TOTAL) == null ? 0 : vulnInfo.get(TOTAL)); if (sevList.stream().filter(summarySevList::contains).count() != summarySevList.size()) { vulnerableAssetCount = Long.valueOf( vulnerabilityRepository.getUniqueHost(assetGroup, vulnSummarySeverity).get(TOTAL).toString()); } for (String vulnType : vulnTargetTypes) { try { if (vulnType.equals(ONPREMSERVER)) { AssetCount totalAssets = assetServiceClient.getTotalAssetsCount(assetGroup, vulnType, null); AssetCountData data = totalAssets.getData(); AssetCountByAppEnvDTO[] assetcount = data.getAssetcount(); Long totalAssetsCount = 0l; for (AssetCountByAppEnvDTO assetCount_Count : assetcount) { if (assetCount_Count.getType().equalsIgnoreCase(vulnType)) { totalAssetsCount = Long.parseLong(assetCount_Count.getCount()); } } totalAssetCount += totalAssetsCount; totalQualysCount += vulnerabilityRepository.getTotalQualysHostCount(assetGroup, vulnType); } else { Request request = new Request(); request.setAg(assetGroup); Map<String, String> filter = new HashMap<>(); filter.put("domain", "Infra & Platforms"); if (vulnType.equals(EC2)) { filter.put("ruleId.keyword", EC2_QUALYS_RULEID); } if (vulnType.equals(VIRTUALMACHINE)) { filter.put("ruleId.keyword", VIRTUALMACHINE_QUALYS_RULEID); } request.setFilter(filter); List<LinkedHashMap<String, Object>> responses = new ArrayList<>(); Map<String, Object> response = new HashMap<>(); ResponseEntity<Object> nonCompliancePolicyRuleresponse = complianceServiceClient .getNonCompliancePolicyByRule(request); if (nonCompliancePolicyRuleresponse != null) { Map<String, Object> responseBody = (Map<String, Object>) nonCompliancePolicyRuleresponse .getBody(); Map<String, Object> dataResponseMap = (Map<String, Object>) responseBody.get("data"); responses = (List<LinkedHashMap<String, Object>>) dataResponseMap.get("response"); if (responses.size() > 0) { response = responses.get(0); totalAssetCount += Long.valueOf(response.get("assetsScanned").toString()); totalQualysCount += Long.valueOf(response.get("passed").toString()); } } } } catch (DataException e) { throw new ServiceException(); } } try { vulnerabilitySummary.put("hosts", totalAssetCount); if (totalQualysCount > totalAssetCount) { totalQualysCount = totalAssetCount; } long totalVulnerableAssets = totalAssetCount - totalQualysCount + vulnerableAssetCount; if (totalVulnerableAssets > totalAssetCount) { totalVulnerableAssets = totalAssetCount; } vulnerabilitySummary.put(TOTAL_VULN_ASSETS, totalVulnerableAssets); float compliantCount = (float) totalAssetCount - totalVulnerableAssets; float compliantpercent = 100; if (totalAssetCount > 0) { compliantpercent = (compliantCount / totalAssetCount) * 100; } DecimalFormat df = new DecimalFormat("#.00"); vulnerabilitySummary.put("compliantpercent", Math.floor(Float.valueOf(df.format(compliantpercent)))); vulnerabilitySummary.put("hostsScanned", totalQualysCount); vulnerabilitySummary.put("hostsNotScanned", totalAssetCount - totalQualysCount); if (totalAssetCount > 0) { vulnerabilitySummary.put("hostsScanCoverage", Math.floor((1.0 * totalQualysCount / totalAssetCount) * 100)); } else { vulnerabilitySummary.put("hostsScanCoverage", 0); } } catch (Exception e) { logger.error(e); throw new ServiceException(e); } if (vulnerabilitySummary.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return vulnerabilitySummary; } }  List<Map<String, Object>> getVulnerabilitiesDetails(String assetGroup, Map<String, String> filter); @SuppressWarnings("unchecked") List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup,
			Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size); List<Map<String, Object>> getResourcedetailsByResourceId(String assetGroup,
			List<String> listDistinctResourceId, boolean flag); @SuppressWarnings({ "unchecked" }) Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity); List<Map<String, Object>> getVulnerabilityByAppAndEnv(String assetGroup, String filter, String application); List<Map<String, Object>> getVulnerabilityTrend(String assetGroup, Map<String, String> filter, Date from,
			Date to); List<Map<String, Object>> getVulnerabilityNewOpenTrend(String assetGroup, String severity, Date from); List<Map<String, Object>> getVulnerabilitiesDistribution(String assetGroup); Object filterMatchingCollectionElements(List<Map<String, Object>> masterDetailList, String searchText,
			boolean b); Map<String, Object> getVulnerabilitysummaryByResourceId(String instanceId); List<Map<String, Object>> getVulnerabilityDetailsByResourceId(String instanceId); List<Map<String, Object>> getAgingSummary(String assetGroup); List<Map<String, Object>> getVulnerabilityByQid(String qid); @SuppressWarnings("unchecked") Map<String, Integer> getHighestLowestPerformers(String assetGroup, String severity, String type); List<Map<String, Object>> getDistributionSummaryByInfraType(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByEnv(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByVulnType(String assetGroup, String severity); List<Map<String, Object>> getRemediationActionsSummary(String assetGroup, String severity); boolean createTrendAnnotation(TrendNote request); List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from); boolean deleteTrendAnnotation(String noteId); Map<String, Object> getVulnerabilitySummaryByAssets(String assetGroup); List<Map<String, Object>> getVulnerabilityAssetsTrend(String assetGroup, String severity, Date from); Map<String, Map<String, String>> getDirectorsForAGByApp(Set<String> appNames); ResponseEntity<Object> formatException(ServiceException e); Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate,
			LocalDate endDate, String trendCategory); void useRealTimeDataForLatestDate(List<Map<String, Object>> trendList, String ag, String trendCategory,
			String ruleId, String domain); List<String> getResourceId(List<Map<String, Object>> vulnerabilityOccuranceList); List<Map<String, Object>> getCartesianProduct(List<Map<String, Object>> vulnerabilityOccuranceList,
			List<Map<String, Object>> resourceIdDetails); int vulnerabilityAssetCount(String assetGroup, Map<String, String> termsFilter, String applicationFilter,
			String environmentFilter, int from, int size); int countForTargetType(String assetGroup, String parentType, Map<String, String> termsFilter,
			String applicationFilter, String environmentFilter, int from, int size); }
VulnerabilityService implements Constants { @SuppressWarnings({ "unchecked" }) public Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity) throws ServiceException { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); Map<String, Object> vulnerabilitySummary = new HashMap<>(); List<Map<String, Object>> severityInfo = new ArrayList<>(); if (vulnTargetTypes.isEmpty()) { for (int i = 3; i <= 5; i++) { Map<String, Object> sevInfo = new HashMap<>(); sevInfo.put(SEVERITY, "S" + i); sevInfo.put(SEVEITY_LEVEL, i); sevInfo.put(COUNT, 0); sevInfo.put("appCount", 0); sevInfo.put("hostCount", 0); sevInfo.put(UNIQUE_VULN_COUNT, 0); sevInfo.put(VULN_COUNT, 0); severityInfo.add(sevInfo); } vulnerabilitySummary.put(SEV_INFO, severityInfo); vulnerabilitySummary.put(VULNEREBILITIES, 0); vulnerabilitySummary.put("hosts", 0); vulnerabilitySummary.put(TOTAL_VULN_ASSETS, 0); vulnerabilitySummary.put("compliantpercent", 100); vulnerabilitySummary.put("assetsWithVulns", 0); return vulnerabilitySummary; } else { Map<String, Map<String, Object>> queryResults = new HashMap<>(); long totalQualysCount = 0; long vulnerableAssetCount = 0; long totalAssetCount = 0; ExecutorService executor = Executors.newFixedThreadPool(3); executor.execute(() -> { queryResults.put("uniqueHost", vulnerabilityRepository.getUniqueHost(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("VulnInfo", vulnerabilityRepository.getVulnInfo(assetGroup, reqSeverity)); }); executor.execute(() -> { queryResults.put("uniqueApp", vulnerabilityRepository.getUniqueApp(assetGroup)); }); executor.shutdown(); while (!executor.isTerminated()) { } Map<String, Object> uniqueHost = queryResults.get("uniqueHost"); Map<String, Object> vulnInfo = queryResults.get("VulnInfo"); Map<String, Object> uniqueApp = queryResults.get("uniqueApp"); List<String> sevList = Arrays.asList(reqSeverity.split(",")); List<String> summarySevList = Arrays.asList(vulnSummarySeverity.split(",")); Map<String, Object> sevVulnInfo; Map<String, Object> vulnInfoMap; List<Map<String, Object>> sevVulnfoList = new ArrayList<>(); vulnerabilitySummary.put(SEV_INFO, sevVulnfoList); for (String sev : sevList) { sevVulnInfo = new HashMap<>(); sevVulnInfo.put(SEVEITY_LEVEL, Integer.valueOf(sev)); sevVulnInfo.put(SEVERITY, "S" + sev); sevVulnInfo.put("hostCount", uniqueHost.get(sev) == null ? 0 : uniqueHost.get(sev)); if (summarySevList.contains(sev)) { vulnerableAssetCount += Long.valueOf(sevVulnInfo.get("hostCount").toString()); } vulnInfoMap = (Map<String, Object>) vulnInfo.get(sev); if (vulnInfoMap != null) { sevVulnInfo.put(COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(VULN_COUNT, vulnInfoMap.get(VULN_COUNT)); sevVulnInfo.put(UNIQUE_VULN_COUNT, vulnInfoMap.get(UNIQUE_VULN_COUNT)); } else { sevVulnInfo.put(COUNT, 0); sevVulnInfo.put(VULN_COUNT, 0); sevVulnInfo.put(UNIQUE_VULN_COUNT, 0); } sevVulnInfo.put("appCount", uniqueApp.get(sev) == null ? 0 : uniqueApp.get(sev)); sevVulnfoList.add(sevVulnInfo); } vulnerabilitySummary.put(UNIQUE_VULN_COUNT, sevVulnfoList.stream() .mapToLong(sevData -> Long.valueOf(sevData.get(UNIQUE_VULN_COUNT).toString())).sum()); vulnerabilitySummary.put("assetsWithVulns", uniqueHost.get(TOTAL) == null ? 0 : uniqueHost.get(TOTAL)); vulnerabilitySummary.put(VULNEREBILITIES, vulnInfo.get(TOTAL) == null ? 0 : vulnInfo.get(TOTAL)); if (sevList.stream().filter(summarySevList::contains).count() != summarySevList.size()) { vulnerableAssetCount = Long.valueOf( vulnerabilityRepository.getUniqueHost(assetGroup, vulnSummarySeverity).get(TOTAL).toString()); } for (String vulnType : vulnTargetTypes) { try { if (vulnType.equals(ONPREMSERVER)) { AssetCount totalAssets = assetServiceClient.getTotalAssetsCount(assetGroup, vulnType, null); AssetCountData data = totalAssets.getData(); AssetCountByAppEnvDTO[] assetcount = data.getAssetcount(); Long totalAssetsCount = 0l; for (AssetCountByAppEnvDTO assetCount_Count : assetcount) { if (assetCount_Count.getType().equalsIgnoreCase(vulnType)) { totalAssetsCount = Long.parseLong(assetCount_Count.getCount()); } } totalAssetCount += totalAssetsCount; totalQualysCount += vulnerabilityRepository.getTotalQualysHostCount(assetGroup, vulnType); } else { Request request = new Request(); request.setAg(assetGroup); Map<String, String> filter = new HashMap<>(); filter.put("domain", "Infra & Platforms"); if (vulnType.equals(EC2)) { filter.put("ruleId.keyword", EC2_QUALYS_RULEID); } if (vulnType.equals(VIRTUALMACHINE)) { filter.put("ruleId.keyword", VIRTUALMACHINE_QUALYS_RULEID); } request.setFilter(filter); List<LinkedHashMap<String, Object>> responses = new ArrayList<>(); Map<String, Object> response = new HashMap<>(); ResponseEntity<Object> nonCompliancePolicyRuleresponse = complianceServiceClient .getNonCompliancePolicyByRule(request); if (nonCompliancePolicyRuleresponse != null) { Map<String, Object> responseBody = (Map<String, Object>) nonCompliancePolicyRuleresponse .getBody(); Map<String, Object> dataResponseMap = (Map<String, Object>) responseBody.get("data"); responses = (List<LinkedHashMap<String, Object>>) dataResponseMap.get("response"); if (responses.size() > 0) { response = responses.get(0); totalAssetCount += Long.valueOf(response.get("assetsScanned").toString()); totalQualysCount += Long.valueOf(response.get("passed").toString()); } } } } catch (DataException e) { throw new ServiceException(); } } try { vulnerabilitySummary.put("hosts", totalAssetCount); if (totalQualysCount > totalAssetCount) { totalQualysCount = totalAssetCount; } long totalVulnerableAssets = totalAssetCount - totalQualysCount + vulnerableAssetCount; if (totalVulnerableAssets > totalAssetCount) { totalVulnerableAssets = totalAssetCount; } vulnerabilitySummary.put(TOTAL_VULN_ASSETS, totalVulnerableAssets); float compliantCount = (float) totalAssetCount - totalVulnerableAssets; float compliantpercent = 100; if (totalAssetCount > 0) { compliantpercent = (compliantCount / totalAssetCount) * 100; } DecimalFormat df = new DecimalFormat("#.00"); vulnerabilitySummary.put("compliantpercent", Math.floor(Float.valueOf(df.format(compliantpercent)))); vulnerabilitySummary.put("hostsScanned", totalQualysCount); vulnerabilitySummary.put("hostsNotScanned", totalAssetCount - totalQualysCount); if (totalAssetCount > 0) { vulnerabilitySummary.put("hostsScanCoverage", Math.floor((1.0 * totalQualysCount / totalAssetCount) * 100)); } else { vulnerabilitySummary.put("hostsScanCoverage", 0); } } catch (Exception e) { logger.error(e); throw new ServiceException(e); } if (vulnerabilitySummary.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return vulnerabilitySummary; } }  List<Map<String, Object>> getVulnerabilitiesDetails(String assetGroup, Map<String, String> filter); @SuppressWarnings("unchecked") List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup,
			Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size); List<Map<String, Object>> getResourcedetailsByResourceId(String assetGroup,
			List<String> listDistinctResourceId, boolean flag); @SuppressWarnings({ "unchecked" }) Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity); List<Map<String, Object>> getVulnerabilityByAppAndEnv(String assetGroup, String filter, String application); List<Map<String, Object>> getVulnerabilityTrend(String assetGroup, Map<String, String> filter, Date from,
			Date to); List<Map<String, Object>> getVulnerabilityNewOpenTrend(String assetGroup, String severity, Date from); List<Map<String, Object>> getVulnerabilitiesDistribution(String assetGroup); Object filterMatchingCollectionElements(List<Map<String, Object>> masterDetailList, String searchText,
			boolean b); Map<String, Object> getVulnerabilitysummaryByResourceId(String instanceId); List<Map<String, Object>> getVulnerabilityDetailsByResourceId(String instanceId); List<Map<String, Object>> getAgingSummary(String assetGroup); List<Map<String, Object>> getVulnerabilityByQid(String qid); @SuppressWarnings("unchecked") Map<String, Integer> getHighestLowestPerformers(String assetGroup, String severity, String type); List<Map<String, Object>> getDistributionSummaryByInfraType(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByEnv(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByVulnType(String assetGroup, String severity); List<Map<String, Object>> getRemediationActionsSummary(String assetGroup, String severity); boolean createTrendAnnotation(TrendNote request); List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from); boolean deleteTrendAnnotation(String noteId); Map<String, Object> getVulnerabilitySummaryByAssets(String assetGroup); List<Map<String, Object>> getVulnerabilityAssetsTrend(String assetGroup, String severity, Date from); Map<String, Map<String, String>> getDirectorsForAGByApp(Set<String> appNames); ResponseEntity<Object> formatException(ServiceException e); Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate,
			LocalDate endDate, String trendCategory); void useRealTimeDataForLatestDate(List<Map<String, Object>> trendList, String ag, String trendCategory,
			String ruleId, String domain); List<String> getResourceId(List<Map<String, Object>> vulnerabilityOccuranceList); List<Map<String, Object>> getCartesianProduct(List<Map<String, Object>> vulnerabilityOccuranceList,
			List<Map<String, Object>> resourceIdDetails); int vulnerabilityAssetCount(String assetGroup, Map<String, String> termsFilter, String applicationFilter,
			String environmentFilter, int from, int size); int countForTargetType(String assetGroup, String parentType, Map<String, String> termsFilter,
			String applicationFilter, String environmentFilter, int from, int size);  }