@Test public void testFetchVulnSummary() throws Exception { String vulnSummaryJson = "{\"data\":{\"output\":{\"hosts\":7192,\"vulnerabilities\":132285,\"totalVulnerableAssets\":5815}},\"message\":\"success\"}"; when(HttpUtil.get(anyString(),anyString())).thenReturn(vulnSummaryJson); Map<String, Object> vulnSummary = AssetGroupUtil.fetchVulnSummary("", "",""); assertThat(vulnSummary.get("total"), is(7192l)); }
public static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> vulnSummary = new HashMap<>(); try { String vulnSummaryResponse = HttpUtil.get(compapiuri + "/vulnerabilites?ag=" + ag,token); JsonObject vulnSummaryJson = new JsonParser().parse(vulnSummaryResponse).getAsJsonObject(); JsonObject vulnJsonObj = vulnSummaryJson.get("data").getAsJsonObject().get(OUTPUT).getAsJsonObject(); long total = vulnJsonObj.get("hosts").getAsLong(); long noncompliant = vulnJsonObj.get("totalVulnerableAssets").getAsLong(); vulnSummary.put(TOTAL, total); vulnSummary.put(NON_COMPLIANT, noncompliant); vulnSummary.put(COMPLIANT, total - noncompliant); } catch (Exception e) { LOGGER.error("Error retrieving vuln sumamary " , e); throw e; } return vulnSummary; }
AssetGroupUtil { public static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> vulnSummary = new HashMap<>(); try { String vulnSummaryResponse = HttpUtil.get(compapiuri + "/vulnerabilites?ag=" + ag,token); JsonObject vulnSummaryJson = new JsonParser().parse(vulnSummaryResponse).getAsJsonObject(); JsonObject vulnJsonObj = vulnSummaryJson.get("data").getAsJsonObject().get(OUTPUT).getAsJsonObject(); long total = vulnJsonObj.get("hosts").getAsLong(); long noncompliant = vulnJsonObj.get("totalVulnerableAssets").getAsLong(); vulnSummary.put(TOTAL, total); vulnSummary.put(NON_COMPLIANT, noncompliant); vulnSummary.put(COMPLIANT, total - noncompliant); } catch (Exception e) { LOGGER.error("Error retrieving vuln sumamary " , e); throw e; } return vulnSummary; } }
AssetGroupUtil { public static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> vulnSummary = new HashMap<>(); try { String vulnSummaryResponse = HttpUtil.get(compapiuri + "/vulnerabilites?ag=" + ag,token); JsonObject vulnSummaryJson = new JsonParser().parse(vulnSummaryResponse).getAsJsonObject(); JsonObject vulnJsonObj = vulnSummaryJson.get("data").getAsJsonObject().get(OUTPUT).getAsJsonObject(); long total = vulnJsonObj.get("hosts").getAsLong(); long noncompliant = vulnJsonObj.get("totalVulnerableAssets").getAsLong(); vulnSummary.put(TOTAL, total); vulnSummary.put(NON_COMPLIANT, noncompliant); vulnSummary.put(COMPLIANT, total - noncompliant); } catch (Exception e) { LOGGER.error("Error retrieving vuln sumamary " , e); throw e; } return vulnSummary; } private  AssetGroupUtil(); }
AssetGroupUtil { public static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> vulnSummary = new HashMap<>(); try { String vulnSummaryResponse = HttpUtil.get(compapiuri + "/vulnerabilites?ag=" + ag,token); JsonObject vulnSummaryJson = new JsonParser().parse(vulnSummaryResponse).getAsJsonObject(); JsonObject vulnJsonObj = vulnSummaryJson.get("data").getAsJsonObject().get(OUTPUT).getAsJsonObject(); long total = vulnJsonObj.get("hosts").getAsLong(); long noncompliant = vulnJsonObj.get("totalVulnerableAssets").getAsLong(); vulnSummary.put(TOTAL, total); vulnSummary.put(NON_COMPLIANT, noncompliant); vulnSummary.put(COMPLIANT, total - noncompliant); } catch (Exception e) { LOGGER.error("Error retrieving vuln sumamary " , e); throw e; } return vulnSummary; } private  AssetGroupUtil(); @SuppressWarnings("unchecked") static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token); static Map<String, Object> fetchPatchingCompliance(String api, String ag ,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchVulnDistribution(String api, String ag ,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token); static List<Map<String, Object>> fetchRuleComplianceInfo(String compapiuri, String ag,
            List<String> domains ,String token); static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token); static Map<String, Object> fetchTaggingSummary(String compapiuri, String ag ,String token); static Map<String, Object> fetchCertSummary(String compapiuri, String ag ,String token); static List<Map<String, Object>> fetchIssuesInfo(String compapiuri, String ag, List<String> domains ,String token); }
AssetGroupUtil { public static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token) throws Exception { Map<String, Object> vulnSummary = new HashMap<>(); try { String vulnSummaryResponse = HttpUtil.get(compapiuri + "/vulnerabilites?ag=" + ag,token); JsonObject vulnSummaryJson = new JsonParser().parse(vulnSummaryResponse).getAsJsonObject(); JsonObject vulnJsonObj = vulnSummaryJson.get("data").getAsJsonObject().get(OUTPUT).getAsJsonObject(); long total = vulnJsonObj.get("hosts").getAsLong(); long noncompliant = vulnJsonObj.get("totalVulnerableAssets").getAsLong(); vulnSummary.put(TOTAL, total); vulnSummary.put(NON_COMPLIANT, noncompliant); vulnSummary.put(COMPLIANT, total - noncompliant); } catch (Exception e) { LOGGER.error("Error retrieving vuln sumamary " , e); throw e; } return vulnSummary; } private  AssetGroupUtil(); @SuppressWarnings("unchecked") static Map<String, List<String>> fetchAssetGroups(String asstApiUri,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchTypeCounts(String asstApiUri, String ag,String token); static Map<String, Object> fetchPatchingCompliance(String api, String ag ,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchVulnDistribution(String api, String ag ,String token); @SuppressWarnings("unchecked") static List<Map<String, Object>> fetchComplianceInfo(String apiUrl, String ag, List<String> domains ,String token); static List<Map<String, Object>> fetchRuleComplianceInfo(String compapiuri, String ag,
            List<String> domains ,String token); static Map<String, Object> fetchVulnSummary(String compapiuri, String ag ,String token); static Map<String, Object> fetchTaggingSummary(String compapiuri, String ag ,String token); static Map<String, Object> fetchCertSummary(String compapiuri, String ag ,String token); static List<Map<String, Object>> fetchIssuesInfo(String compapiuri, String ag, List<String> domains ,String token);  }