@Test public void getVulnerabilityByQidTest() throws Exception { Map<String, Object> vuln = new HashMap<>(); vuln.put("qid", "123"); vuln.put("vulntype", "type"); vuln.put("severitylevel", "3"); vuln.put("title", "test"); vuln.put("category", ""); vuln.put("lastservicemodificationdatetime", "1234"); vuln.put("publisheddatetime", "123"); vuln.put("patchable", "1"); Map<String, Object> softwarelist = new HashMap<>(); List<Map<String, Object>> softwares = new ArrayList<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put("test", "test"); innerMap.put("test", "test"); softwares.add(innerMap); softwarelist.put("software", softwares); vuln.put("softwarelist", softwarelist); Map<String, Object> vendorreferencelist = new HashMap<>(); List<Map<String, Object>> vendorreference = new ArrayList<>(); vendorreference.add(innerMap); vendorreferencelist.put("vendorreference", vendorreference); vuln.put("vendorreferencelist", vendorreferencelist); vuln.put("diagnosis", "test"); vuln.put("consequence", "test"); vuln.put("solution", "test"); Map<String, Object> bugtraqlist = new HashMap<>(); List<Map<String, Object>> bugtraq = new ArrayList<>(); bugtraq.add(innerMap); bugtraqlist.put("vendorreference", bugtraq); vuln.put("bugtraqlist", bugtraqlist); vuln.put("pciflag", 0); Map<String, Object> pcireasons = new HashMap<>(); List<Map<String, Object>> pcireason = new ArrayList<>(); pcireason.add(innerMap); pcireasons.put("pcireason", pcireason); vuln.put("pcireasons", pcireasons); Map<String, Object> authtypelist = new HashMap<>(); List<Map<String, Object>> authtype = new ArrayList<>(); authtype.add(innerMap); authtypelist.put("authtype", authtype); Map<String, Object> discovery = new HashMap<>(); discovery.put("authtypelist", authtypelist); discovery.put("additionalinfo", "Patch Available"); vuln.put("discovery", discovery); vuln.put("supportedmodules", "test"); Map<String, Object> cvelist = new HashMap<>(); List<Map<String, Object>> cve = new ArrayList<>(); cve.add(innerMap); cvelist.put("cve", cve); vuln.put("cvelist", cvelist); Map<String, Object> cvss = new HashMap<>(); cvss.put("base", 1); cvss.put("temporal", 1); vuln.put("cvssv3", cvss); Map<String, Object> access = new HashMap<>(); access.put("vector", 1); cvss.put("access", access); vuln.put("cvss", cvss); when(vulnerabilityRepository.getVulnerabilityByQid(anyString())).thenReturn(vuln); assertThat(vulnerabilityService.getVulnerabilityByQid("id"), is(notNullValue())); vuln = new HashMap<>(); discovery = new HashMap<>(); discovery.put("additionalinfo", "test"); vuln.put("discovery", discovery); vuln.put("pciflag", 1); when(vulnerabilityRepository.getVulnerabilityByQid(anyString())).thenReturn(vuln); assertThat(vulnerabilityService.getVulnerabilityByQid("id"), is(notNullValue())); when(vulnerabilityRepository.getVulnerabilityByQid(anyString())).thenReturn(new HashMap<>()); assertThat(vulnerabilityService.getVulnerabilityByQid("id"), is(notNullValue())); }
public List<Map<String, Object>> getVulnerabilityByQid(String qid) { List<Map<String, Object>> vulnByCategories = new ArrayList<>(); Map<String, Object> vulnKbData = vulnerabilityRepository.getVulnerabilityByQid(qid); vulnByCategories.add(formGeneralCategory(vulnKbData)); vulnByCategories.add(formDetailsCategory(vulnKbData)); vulnByCategories.add(formSoftwareCategory(vulnKbData)); vulnByCategories.add(formImpactCategory(vulnKbData)); vulnByCategories.add(formThreatCategory(vulnKbData)); vulnByCategories.add(formSolutionCategory(vulnKbData)); vulnByCategories.add(formExploitabilityCategory(vulnKbData)); vulnByCategories.add(formAssociatedMalware(vulnKbData)); return vulnByCategories; }
VulnerabilityService implements Constants { public List<Map<String, Object>> getVulnerabilityByQid(String qid) { List<Map<String, Object>> vulnByCategories = new ArrayList<>(); Map<String, Object> vulnKbData = vulnerabilityRepository.getVulnerabilityByQid(qid); vulnByCategories.add(formGeneralCategory(vulnKbData)); vulnByCategories.add(formDetailsCategory(vulnKbData)); vulnByCategories.add(formSoftwareCategory(vulnKbData)); vulnByCategories.add(formImpactCategory(vulnKbData)); vulnByCategories.add(formThreatCategory(vulnKbData)); vulnByCategories.add(formSolutionCategory(vulnKbData)); vulnByCategories.add(formExploitabilityCategory(vulnKbData)); vulnByCategories.add(formAssociatedMalware(vulnKbData)); return vulnByCategories; } }
VulnerabilityService implements Constants { public List<Map<String, Object>> getVulnerabilityByQid(String qid) { List<Map<String, Object>> vulnByCategories = new ArrayList<>(); Map<String, Object> vulnKbData = vulnerabilityRepository.getVulnerabilityByQid(qid); vulnByCategories.add(formGeneralCategory(vulnKbData)); vulnByCategories.add(formDetailsCategory(vulnKbData)); vulnByCategories.add(formSoftwareCategory(vulnKbData)); vulnByCategories.add(formImpactCategory(vulnKbData)); vulnByCategories.add(formThreatCategory(vulnKbData)); vulnByCategories.add(formSolutionCategory(vulnKbData)); vulnByCategories.add(formExploitabilityCategory(vulnKbData)); vulnByCategories.add(formAssociatedMalware(vulnKbData)); return vulnByCategories; }  }
VulnerabilityService implements Constants { public List<Map<String, Object>> getVulnerabilityByQid(String qid) { List<Map<String, Object>> vulnByCategories = new ArrayList<>(); Map<String, Object> vulnKbData = vulnerabilityRepository.getVulnerabilityByQid(qid); vulnByCategories.add(formGeneralCategory(vulnKbData)); vulnByCategories.add(formDetailsCategory(vulnKbData)); vulnByCategories.add(formSoftwareCategory(vulnKbData)); vulnByCategories.add(formImpactCategory(vulnKbData)); vulnByCategories.add(formThreatCategory(vulnKbData)); vulnByCategories.add(formSolutionCategory(vulnKbData)); vulnByCategories.add(formExploitabilityCategory(vulnKbData)); vulnByCategories.add(formAssociatedMalware(vulnKbData)); return vulnByCategories; }  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 { public List<Map<String, Object>> getVulnerabilityByQid(String qid) { List<Map<String, Object>> vulnByCategories = new ArrayList<>(); Map<String, Object> vulnKbData = vulnerabilityRepository.getVulnerabilityByQid(qid); vulnByCategories.add(formGeneralCategory(vulnKbData)); vulnByCategories.add(formDetailsCategory(vulnKbData)); vulnByCategories.add(formSoftwareCategory(vulnKbData)); vulnByCategories.add(formImpactCategory(vulnKbData)); vulnByCategories.add(formThreatCategory(vulnKbData)); vulnByCategories.add(formSolutionCategory(vulnKbData)); vulnByCategories.add(formExploitabilityCategory(vulnKbData)); vulnByCategories.add(formAssociatedMalware(vulnKbData)); return vulnByCategories; }  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);  }