@SuppressWarnings("unchecked") @Test public void getAllVulnerabilitiesDetailsByAssetGroupTest() throws Exception { List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map1 = new HashMap<String, Object>(); Map<String, String> mapf = new HashMap<String, String>(); map.put("ac", "66"); map.put("acname", "second"); map.put("res", "int"); map.put("vp", "brt3"); map.put("geid", "amigo"); map1.put("rr", "345"); map1.put("fd", "sec"); map1.put("ij", "i"); map1.put("cid", "b3"); map1.put("mad", "mi"); vulnerabilitiesDetails.add(map); vulnerabilitiesDetails.add(map1); List<Map<String, Object>> resourceIdDetails = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> abc = new ArrayList<Map<String, Object>>(); Map<String, Object> map2 = new HashMap<String, Object>(); Map<String, Object> map3 = new HashMap<String, Object>(); map2.put("s", "s3445"); map2.put("ced", "866"); map2.put("cif=", "1"); map2.put("lna", "21.0"); map2.put("cat", "pp"); map3.put("ver", "fr"); map3.put("ed", "cd85"); map3.put("ifl=", "1"); map3.put("ule", "2261.0"); map3.put("sif", "app7"); resourceIdDetails.add(map2); resourceIdDetails.add(map3); String assetGroup = "abc"; Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", "true"); String targetType = "vulninfo"; String searchText = ""; int from = 0; int size = 0; List<String> occurrenceFieldList = null; ReflectionTestUtils.setField(vulnerabilityService, "vulnTypes", "ec2"); ReflectionTestUtils.setField(vulnerabilityService, "vulnOccurrenceFields", "severity,_resourceid,pciflag,_vulnage,vulntype,title,classification,_status,qid,patchable,category"); ReflectionTestUtils.setField(vulnerabilityService, "vulnResourceIdFields", "tags.Name,accountid,accountname,tags.Environment,tags.Application,privateipaddress,instanceid,region,availabilityzone,imageid,platform,privatednsname,instancetype,subnetid,_resourceid,publicipaddress,publicdnsname,vpcid"); ReflectionTestUtils.setField(vulnerabilityService, "vulnResourceIdFieldsBoth", "tags.Name,accountid,accountname,tags.Environment,tags.Application,privateipaddress,instanceid,region,availabilityzone,imageid,platform,privatednsname,instancetype,subnetid,_resourceid,publicipaddress,publicdnsname,vpcid"); when(vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilter, occurrenceFieldList, from, size, mustTermsFilter)).thenReturn(vulnerabilitiesDetails); when(vulnerabilityRepository.getDetailsByResourceId(anyString(), anyMap(), anyList(), anyMap())) .thenReturn(resourceIdDetails); assertThat(vulnerabilityService.getAllVulnerabilitiesDetailsByAssetGroup(assetGroup, mapf, "pac", "pro", searchText, from, size), is(notNullValue())); size = 25; ReflectionTestUtils.setField(vulnerabilityService, "vulnOccurrenceFields", "severity,_resourceid,pciflag,_vulnage,vulntype,title,classification,_status,qid,patchable,category"); ReflectionTestUtils.setField(vulnerabilityService, "vulnResourceIdFields", "tags.Name,accountid,accountname,tags.Environment,tags.Application,privateipaddress,instanceid,region,availabilityzone,imageid,platform,privatednsname,instancetype,subnetid,_resourceid,publicipaddress,publicdnsname,vpcid"); when(vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilter, occurrenceFieldList, from, size, mustTermsFilter)).thenReturn(vulnerabilitiesDetails); when(vulnerabilityRepository.getDetailsByResourceId(anyString(), anyMap(), anyList(), anyMap())) .thenReturn(resourceIdDetails); assertThat(vulnerabilityService.getAllVulnerabilitiesDetailsByAssetGroup(assetGroup, mapf, "pac", "pro", searchText, from, size), is(notNullValue())); }
@SuppressWarnings("unchecked") public List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup, Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size) throws Exception { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); boolean flag = false; if (vulnTargetTypes.size() > 1) { flag = true; } List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<>(); List<Map<String, Object>> vulnerabilitiesDetailsFinal = new ArrayList<>(); List<String> occurrenceFieldList = Arrays.asList(vulnOccurrenceFields.split(",")); for (String parentType : vulnTargetTypes) { String targetType = "vulninfo"; Map<String, Object> mustFilterMap = new LinkedHashMap<>(); mustFilterMap.put("latest", "true"); Map<String, Object> parentBool = new HashMap<>(); List<Map<String, Object>> mustList = new ArrayList<>(); Map<String, Object> matchMap = new HashMap<>(); Map<String, String> match = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); for (Map.Entry<String, String> entry : filter.entrySet()) { List<String> severities = Arrays.asList(entry.getValue().split(",")); mustTermsFilter.put(entry.getKey(), severities); } match.put(Constants.LATEST, Constants.TRUE); matchMap.put(Constants.MATCH, match); mustList.add(matchMap); if (applicationFilter != null) { Map<String, String> applicationFilterMap = new HashMap<String, String>(); Map<String, Object> applicationFilterMap1 = new HashMap<String, Object>(); applicationFilterMap.put("tags.Application.keyword", applicationFilter); applicationFilterMap1.put("match", applicationFilterMap); mustList.add(applicationFilterMap1); } if (environmentFilter != null) { Map<String, String> environmentFilterMap = new HashMap<String, String>(); Map<String, Object> environmentFilterMap1 = new HashMap<String, Object>(); environmentFilterMap.put("tags.Environment.keyword", environmentFilter); environmentFilterMap1.put("match", environmentFilterMap); mustList.add(environmentFilterMap1); } parentBool.put("must", mustList); Map<String, Object> queryMap = new HashMap<>(); queryMap.put("bool", parentBool); Map<String, Object> parentEntryMap = new LinkedHashMap<>(); parentEntryMap.put("parent_type", parentType); parentEntryMap.put("query", queryMap); mustFilterMap.put("has_parent", parentEntryMap); try { vulnerabilitiesDetails = vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilterMap,occurrenceFieldList, from, size, mustTermsFilter); vulnerabilitiesDetailsFinal.addAll(vulnerabilitiesDetails); } catch (Exception e) { logger.error("Error in getAllVulnerabilitiesDetailsByAssetGroup ", e); throw e; } } List<String> listDistinctResourceId = getResourceId(vulnerabilitiesDetailsFinal); List<Map<String, Object>> resourceIdDetails = getResourcedetailsByResourceId(assetGroup, listDistinctResourceId, flag); List<Map<String, Object>> cartesianResultList = getCartesianProduct(vulnerabilitiesDetailsFinal, resourceIdDetails); cartesianResultList = (List<Map<String, Object>>) filterMatchingCollectionElements(cartesianResultList, searchText, true); for (Map<String, Object> map : cartesianResultList) { List<String> underscoreKeys = new ArrayList<String>(); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getKey().startsWith("_")) { underscoreKeys.add(entry.getKey()); } } underscoreKeys.forEach(underscoreElement -> { String underscoreRemovedKey = underscoreElement.substring(1, underscoreElement.length()); map.put(underscoreRemovedKey, map.get(underscoreElement)); map.remove(underscoreElement); }); } return cartesianResultList; }
VulnerabilityService implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup, Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size) throws Exception { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); boolean flag = false; if (vulnTargetTypes.size() > 1) { flag = true; } List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<>(); List<Map<String, Object>> vulnerabilitiesDetailsFinal = new ArrayList<>(); List<String> occurrenceFieldList = Arrays.asList(vulnOccurrenceFields.split(",")); for (String parentType : vulnTargetTypes) { String targetType = "vulninfo"; Map<String, Object> mustFilterMap = new LinkedHashMap<>(); mustFilterMap.put("latest", "true"); Map<String, Object> parentBool = new HashMap<>(); List<Map<String, Object>> mustList = new ArrayList<>(); Map<String, Object> matchMap = new HashMap<>(); Map<String, String> match = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); for (Map.Entry<String, String> entry : filter.entrySet()) { List<String> severities = Arrays.asList(entry.getValue().split(",")); mustTermsFilter.put(entry.getKey(), severities); } match.put(Constants.LATEST, Constants.TRUE); matchMap.put(Constants.MATCH, match); mustList.add(matchMap); if (applicationFilter != null) { Map<String, String> applicationFilterMap = new HashMap<String, String>(); Map<String, Object> applicationFilterMap1 = new HashMap<String, Object>(); applicationFilterMap.put("tags.Application.keyword", applicationFilter); applicationFilterMap1.put("match", applicationFilterMap); mustList.add(applicationFilterMap1); } if (environmentFilter != null) { Map<String, String> environmentFilterMap = new HashMap<String, String>(); Map<String, Object> environmentFilterMap1 = new HashMap<String, Object>(); environmentFilterMap.put("tags.Environment.keyword", environmentFilter); environmentFilterMap1.put("match", environmentFilterMap); mustList.add(environmentFilterMap1); } parentBool.put("must", mustList); Map<String, Object> queryMap = new HashMap<>(); queryMap.put("bool", parentBool); Map<String, Object> parentEntryMap = new LinkedHashMap<>(); parentEntryMap.put("parent_type", parentType); parentEntryMap.put("query", queryMap); mustFilterMap.put("has_parent", parentEntryMap); try { vulnerabilitiesDetails = vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilterMap,occurrenceFieldList, from, size, mustTermsFilter); vulnerabilitiesDetailsFinal.addAll(vulnerabilitiesDetails); } catch (Exception e) { logger.error("Error in getAllVulnerabilitiesDetailsByAssetGroup ", e); throw e; } } List<String> listDistinctResourceId = getResourceId(vulnerabilitiesDetailsFinal); List<Map<String, Object>> resourceIdDetails = getResourcedetailsByResourceId(assetGroup, listDistinctResourceId, flag); List<Map<String, Object>> cartesianResultList = getCartesianProduct(vulnerabilitiesDetailsFinal, resourceIdDetails); cartesianResultList = (List<Map<String, Object>>) filterMatchingCollectionElements(cartesianResultList, searchText, true); for (Map<String, Object> map : cartesianResultList) { List<String> underscoreKeys = new ArrayList<String>(); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getKey().startsWith("_")) { underscoreKeys.add(entry.getKey()); } } underscoreKeys.forEach(underscoreElement -> { String underscoreRemovedKey = underscoreElement.substring(1, underscoreElement.length()); map.put(underscoreRemovedKey, map.get(underscoreElement)); map.remove(underscoreElement); }); } return cartesianResultList; } }
VulnerabilityService implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup, Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size) throws Exception { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); boolean flag = false; if (vulnTargetTypes.size() > 1) { flag = true; } List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<>(); List<Map<String, Object>> vulnerabilitiesDetailsFinal = new ArrayList<>(); List<String> occurrenceFieldList = Arrays.asList(vulnOccurrenceFields.split(",")); for (String parentType : vulnTargetTypes) { String targetType = "vulninfo"; Map<String, Object> mustFilterMap = new LinkedHashMap<>(); mustFilterMap.put("latest", "true"); Map<String, Object> parentBool = new HashMap<>(); List<Map<String, Object>> mustList = new ArrayList<>(); Map<String, Object> matchMap = new HashMap<>(); Map<String, String> match = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); for (Map.Entry<String, String> entry : filter.entrySet()) { List<String> severities = Arrays.asList(entry.getValue().split(",")); mustTermsFilter.put(entry.getKey(), severities); } match.put(Constants.LATEST, Constants.TRUE); matchMap.put(Constants.MATCH, match); mustList.add(matchMap); if (applicationFilter != null) { Map<String, String> applicationFilterMap = new HashMap<String, String>(); Map<String, Object> applicationFilterMap1 = new HashMap<String, Object>(); applicationFilterMap.put("tags.Application.keyword", applicationFilter); applicationFilterMap1.put("match", applicationFilterMap); mustList.add(applicationFilterMap1); } if (environmentFilter != null) { Map<String, String> environmentFilterMap = new HashMap<String, String>(); Map<String, Object> environmentFilterMap1 = new HashMap<String, Object>(); environmentFilterMap.put("tags.Environment.keyword", environmentFilter); environmentFilterMap1.put("match", environmentFilterMap); mustList.add(environmentFilterMap1); } parentBool.put("must", mustList); Map<String, Object> queryMap = new HashMap<>(); queryMap.put("bool", parentBool); Map<String, Object> parentEntryMap = new LinkedHashMap<>(); parentEntryMap.put("parent_type", parentType); parentEntryMap.put("query", queryMap); mustFilterMap.put("has_parent", parentEntryMap); try { vulnerabilitiesDetails = vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilterMap,occurrenceFieldList, from, size, mustTermsFilter); vulnerabilitiesDetailsFinal.addAll(vulnerabilitiesDetails); } catch (Exception e) { logger.error("Error in getAllVulnerabilitiesDetailsByAssetGroup ", e); throw e; } } List<String> listDistinctResourceId = getResourceId(vulnerabilitiesDetailsFinal); List<Map<String, Object>> resourceIdDetails = getResourcedetailsByResourceId(assetGroup, listDistinctResourceId, flag); List<Map<String, Object>> cartesianResultList = getCartesianProduct(vulnerabilitiesDetailsFinal, resourceIdDetails); cartesianResultList = (List<Map<String, Object>>) filterMatchingCollectionElements(cartesianResultList, searchText, true); for (Map<String, Object> map : cartesianResultList) { List<String> underscoreKeys = new ArrayList<String>(); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getKey().startsWith("_")) { underscoreKeys.add(entry.getKey()); } } underscoreKeys.forEach(underscoreElement -> { String underscoreRemovedKey = underscoreElement.substring(1, underscoreElement.length()); map.put(underscoreRemovedKey, map.get(underscoreElement)); map.remove(underscoreElement); }); } return cartesianResultList; }  }
VulnerabilityService implements Constants { @SuppressWarnings("unchecked") public List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup, Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size) throws Exception { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); boolean flag = false; if (vulnTargetTypes.size() > 1) { flag = true; } List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<>(); List<Map<String, Object>> vulnerabilitiesDetailsFinal = new ArrayList<>(); List<String> occurrenceFieldList = Arrays.asList(vulnOccurrenceFields.split(",")); for (String parentType : vulnTargetTypes) { String targetType = "vulninfo"; Map<String, Object> mustFilterMap = new LinkedHashMap<>(); mustFilterMap.put("latest", "true"); Map<String, Object> parentBool = new HashMap<>(); List<Map<String, Object>> mustList = new ArrayList<>(); Map<String, Object> matchMap = new HashMap<>(); Map<String, String> match = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); for (Map.Entry<String, String> entry : filter.entrySet()) { List<String> severities = Arrays.asList(entry.getValue().split(",")); mustTermsFilter.put(entry.getKey(), severities); } match.put(Constants.LATEST, Constants.TRUE); matchMap.put(Constants.MATCH, match); mustList.add(matchMap); if (applicationFilter != null) { Map<String, String> applicationFilterMap = new HashMap<String, String>(); Map<String, Object> applicationFilterMap1 = new HashMap<String, Object>(); applicationFilterMap.put("tags.Application.keyword", applicationFilter); applicationFilterMap1.put("match", applicationFilterMap); mustList.add(applicationFilterMap1); } if (environmentFilter != null) { Map<String, String> environmentFilterMap = new HashMap<String, String>(); Map<String, Object> environmentFilterMap1 = new HashMap<String, Object>(); environmentFilterMap.put("tags.Environment.keyword", environmentFilter); environmentFilterMap1.put("match", environmentFilterMap); mustList.add(environmentFilterMap1); } parentBool.put("must", mustList); Map<String, Object> queryMap = new HashMap<>(); queryMap.put("bool", parentBool); Map<String, Object> parentEntryMap = new LinkedHashMap<>(); parentEntryMap.put("parent_type", parentType); parentEntryMap.put("query", queryMap); mustFilterMap.put("has_parent", parentEntryMap); try { vulnerabilitiesDetails = vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilterMap,occurrenceFieldList, from, size, mustTermsFilter); vulnerabilitiesDetailsFinal.addAll(vulnerabilitiesDetails); } catch (Exception e) { logger.error("Error in getAllVulnerabilitiesDetailsByAssetGroup ", e); throw e; } } List<String> listDistinctResourceId = getResourceId(vulnerabilitiesDetailsFinal); List<Map<String, Object>> resourceIdDetails = getResourcedetailsByResourceId(assetGroup, listDistinctResourceId, flag); List<Map<String, Object>> cartesianResultList = getCartesianProduct(vulnerabilitiesDetailsFinal, resourceIdDetails); cartesianResultList = (List<Map<String, Object>>) filterMatchingCollectionElements(cartesianResultList, searchText, true); for (Map<String, Object> map : cartesianResultList) { List<String> underscoreKeys = new ArrayList<String>(); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getKey().startsWith("_")) { underscoreKeys.add(entry.getKey()); } } underscoreKeys.forEach(underscoreElement -> { String underscoreRemovedKey = underscoreElement.substring(1, underscoreElement.length()); map.put(underscoreRemovedKey, map.get(underscoreElement)); map.remove(underscoreElement); }); } return cartesianResultList; }  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 List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup, Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size) throws Exception { List<String> vulnTargetTypes = getVulnTargetTypes(assetGroup); boolean flag = false; if (vulnTargetTypes.size() > 1) { flag = true; } List<Map<String, Object>> vulnerabilitiesDetails = new ArrayList<>(); List<Map<String, Object>> vulnerabilitiesDetailsFinal = new ArrayList<>(); List<String> occurrenceFieldList = Arrays.asList(vulnOccurrenceFields.split(",")); for (String parentType : vulnTargetTypes) { String targetType = "vulninfo"; Map<String, Object> mustFilterMap = new LinkedHashMap<>(); mustFilterMap.put("latest", "true"); Map<String, Object> parentBool = new HashMap<>(); List<Map<String, Object>> mustList = new ArrayList<>(); Map<String, Object> matchMap = new HashMap<>(); Map<String, String> match = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); for (Map.Entry<String, String> entry : filter.entrySet()) { List<String> severities = Arrays.asList(entry.getValue().split(",")); mustTermsFilter.put(entry.getKey(), severities); } match.put(Constants.LATEST, Constants.TRUE); matchMap.put(Constants.MATCH, match); mustList.add(matchMap); if (applicationFilter != null) { Map<String, String> applicationFilterMap = new HashMap<String, String>(); Map<String, Object> applicationFilterMap1 = new HashMap<String, Object>(); applicationFilterMap.put("tags.Application.keyword", applicationFilter); applicationFilterMap1.put("match", applicationFilterMap); mustList.add(applicationFilterMap1); } if (environmentFilter != null) { Map<String, String> environmentFilterMap = new HashMap<String, String>(); Map<String, Object> environmentFilterMap1 = new HashMap<String, Object>(); environmentFilterMap.put("tags.Environment.keyword", environmentFilter); environmentFilterMap1.put("match", environmentFilterMap); mustList.add(environmentFilterMap1); } parentBool.put("must", mustList); Map<String, Object> queryMap = new HashMap<>(); queryMap.put("bool", parentBool); Map<String, Object> parentEntryMap = new LinkedHashMap<>(); parentEntryMap.put("parent_type", parentType); parentEntryMap.put("query", queryMap); mustFilterMap.put("has_parent", parentEntryMap); try { vulnerabilitiesDetails = vulnerabilityRepository.getAllVulnerabilitiesByAssetGroup(assetGroup, targetType, mustFilterMap,occurrenceFieldList, from, size, mustTermsFilter); vulnerabilitiesDetailsFinal.addAll(vulnerabilitiesDetails); } catch (Exception e) { logger.error("Error in getAllVulnerabilitiesDetailsByAssetGroup ", e); throw e; } } List<String> listDistinctResourceId = getResourceId(vulnerabilitiesDetailsFinal); List<Map<String, Object>> resourceIdDetails = getResourcedetailsByResourceId(assetGroup, listDistinctResourceId, flag); List<Map<String, Object>> cartesianResultList = getCartesianProduct(vulnerabilitiesDetailsFinal, resourceIdDetails); cartesianResultList = (List<Map<String, Object>>) filterMatchingCollectionElements(cartesianResultList, searchText, true); for (Map<String, Object> map : cartesianResultList) { List<String> underscoreKeys = new ArrayList<String>(); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getKey().startsWith("_")) { underscoreKeys.add(entry.getKey()); } } underscoreKeys.forEach(underscoreElement -> { String underscoreRemovedKey = underscoreElement.substring(1, underscoreElement.length()); map.put(underscoreRemovedKey, map.get(underscoreElement)); map.remove(underscoreElement); }); } return cartesianResultList; }  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);  }