@Test public void getRuleDetailsByEnvironmentFromESTest() throws Exception { String response = "{\"took\":469,\"timed_out\":false,\"_shards\":{\"total\":176,\"successful\":176,\"failed\":0},\"hits\":{\"total\":115456,\"max_score\":0,\"hits\":[]},\"aggregations\":{\"NAME\":{\"doc_count_error_upper_bound\":691,\"sum_other_doc_count\":34323,\"buckets\":[" + "{\"key\":\"key\",\"doc_count\":6258},{\"key\":\"key\",\"doc_count\":3339}]}}}"; ReflectionTestUtils.setField(complianceRepositoryImpl, "esUrl", "dummyEsURL"); ReflectionTestUtils.setField(complianceRepositoryImpl, "mandatoryTags", "Application,Environment"); mockStatic(PacHttpUtils.class); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenReturn(response); complianceRepositoryImpl.getRuleDetailsByEnvironmentFromES("aws-all", "tagging-rule", "app1", null,"test"); complianceRepositoryImpl.getRuleDetailsByEnvironmentFromES("aws-all", "tagging-rule", "app1", "dev","test"); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenThrow(new RuntimeException()); assertThatThrownBy( () -> complianceRepositoryImpl.getRuleDetailsByEnvironmentFromES("aws-all", "tagging-rule", "app1", null,"test")).isInstanceOf(DataException.class); }
public JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application, String searchText,String targetType) throws DataException { String responseJson = null; JsonParser jsonParser; JsonObject resultJson; StringBuilder requestBody = null; StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append(assetGroup).append("/") .append(SEARCH); if (ruleId.contains(TAGGIG_POLICY)) { List<String> tagsList = new ArrayList<>(Arrays.asList(mandatoryTags.split(","))); String body = "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\""+ruleId+"\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}"; char ch='"'; targetType = ch+targetType+ch; body = body + ",{\"terms\":{\"targetType.keyword\":["+targetType+"]}}"; if(application!=null){ body = body + ",{\"match\":{\"tags.Application.keyword\":\""+application+"\"}}"; } body = body + "]"; if (!tagsList.isEmpty()) { body = body + ",\"should\":["; for (String tag : tagsList) { body = body + "{\"match_phrase_prefix\":{\"missingTags\":\"" + tag + "\"}},"; } body = body.substring(0, body.length() - 1); body = body + "]"; body = body + ",\"minimum_should_match\":1"; } body = body + "}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000000}}}}"; requestBody = new StringBuilder(body); }else{ if (StringUtils.isEmpty(searchText)) { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } else { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}},{\"match_phrase_prefix\":{\"_all\":\"" + searchText + "\"}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } } try { responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString()); } catch (Exception e) { logger.error(ERROR_IN_US, e); throw new DataException(e); } jsonParser = new JsonParser(); resultJson = (JsonObject) jsonParser.parse(responseJson); JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(AGGREGATIONS).toString()); return aggsJson.getAsJsonObject("NAME").getAsJsonArray(BUCKETS); }
ComplianceRepositoryImpl implements ComplianceRepository, Constants { public JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application, String searchText,String targetType) throws DataException { String responseJson = null; JsonParser jsonParser; JsonObject resultJson; StringBuilder requestBody = null; StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append(assetGroup).append("/") .append(SEARCH); if (ruleId.contains(TAGGIG_POLICY)) { List<String> tagsList = new ArrayList<>(Arrays.asList(mandatoryTags.split(","))); String body = "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\""+ruleId+"\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}"; char ch='"'; targetType = ch+targetType+ch; body = body + ",{\"terms\":{\"targetType.keyword\":["+targetType+"]}}"; if(application!=null){ body = body + ",{\"match\":{\"tags.Application.keyword\":\""+application+"\"}}"; } body = body + "]"; if (!tagsList.isEmpty()) { body = body + ",\"should\":["; for (String tag : tagsList) { body = body + "{\"match_phrase_prefix\":{\"missingTags\":\"" + tag + "\"}},"; } body = body.substring(0, body.length() - 1); body = body + "]"; body = body + ",\"minimum_should_match\":1"; } body = body + "}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000000}}}}"; requestBody = new StringBuilder(body); }else{ if (StringUtils.isEmpty(searchText)) { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } else { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}},{\"match_phrase_prefix\":{\"_all\":\"" + searchText + "\"}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } } try { responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString()); } catch (Exception e) { logger.error(ERROR_IN_US, e); throw new DataException(e); } jsonParser = new JsonParser(); resultJson = (JsonObject) jsonParser.parse(responseJson); JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(AGGREGATIONS).toString()); return aggsJson.getAsJsonObject("NAME").getAsJsonArray(BUCKETS); } }
ComplianceRepositoryImpl implements ComplianceRepository, Constants { public JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application, String searchText,String targetType) throws DataException { String responseJson = null; JsonParser jsonParser; JsonObject resultJson; StringBuilder requestBody = null; StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append(assetGroup).append("/") .append(SEARCH); if (ruleId.contains(TAGGIG_POLICY)) { List<String> tagsList = new ArrayList<>(Arrays.asList(mandatoryTags.split(","))); String body = "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\""+ruleId+"\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}"; char ch='"'; targetType = ch+targetType+ch; body = body + ",{\"terms\":{\"targetType.keyword\":["+targetType+"]}}"; if(application!=null){ body = body + ",{\"match\":{\"tags.Application.keyword\":\""+application+"\"}}"; } body = body + "]"; if (!tagsList.isEmpty()) { body = body + ",\"should\":["; for (String tag : tagsList) { body = body + "{\"match_phrase_prefix\":{\"missingTags\":\"" + tag + "\"}},"; } body = body.substring(0, body.length() - 1); body = body + "]"; body = body + ",\"minimum_should_match\":1"; } body = body + "}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000000}}}}"; requestBody = new StringBuilder(body); }else{ if (StringUtils.isEmpty(searchText)) { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } else { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}},{\"match_phrase_prefix\":{\"_all\":\"" + searchText + "\"}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } } try { responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString()); } catch (Exception e) { logger.error(ERROR_IN_US, e); throw new DataException(e); } jsonParser = new JsonParser(); resultJson = (JsonObject) jsonParser.parse(responseJson); JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(AGGREGATIONS).toString()); return aggsJson.getAsJsonObject("NAME").getAsJsonArray(BUCKETS); }  }
ComplianceRepositoryImpl implements ComplianceRepository, Constants { public JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application, String searchText,String targetType) throws DataException { String responseJson = null; JsonParser jsonParser; JsonObject resultJson; StringBuilder requestBody = null; StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append(assetGroup).append("/") .append(SEARCH); if (ruleId.contains(TAGGIG_POLICY)) { List<String> tagsList = new ArrayList<>(Arrays.asList(mandatoryTags.split(","))); String body = "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\""+ruleId+"\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}"; char ch='"'; targetType = ch+targetType+ch; body = body + ",{\"terms\":{\"targetType.keyword\":["+targetType+"]}}"; if(application!=null){ body = body + ",{\"match\":{\"tags.Application.keyword\":\""+application+"\"}}"; } body = body + "]"; if (!tagsList.isEmpty()) { body = body + ",\"should\":["; for (String tag : tagsList) { body = body + "{\"match_phrase_prefix\":{\"missingTags\":\"" + tag + "\"}},"; } body = body.substring(0, body.length() - 1); body = body + "]"; body = body + ",\"minimum_should_match\":1"; } body = body + "}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000000}}}}"; requestBody = new StringBuilder(body); }else{ if (StringUtils.isEmpty(searchText)) { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } else { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}},{\"match_phrase_prefix\":{\"_all\":\"" + searchText + "\"}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } } try { responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString()); } catch (Exception e) { logger.error(ERROR_IN_US, e); throw new DataException(e); } jsonParser = new JsonParser(); resultJson = (JsonObject) jsonParser.parse(responseJson); JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(AGGREGATIONS).toString()); return aggsJson.getAsJsonObject("NAME").getAsJsonArray(BUCKETS); }  long getIssuesCount(String assetGroup, String ruleId, String domain); @SuppressWarnings("rawtypes") ResponseWithOrder getIssuesFromES(Request request); @SuppressWarnings("rawtypes") Map<String, Long> getTagging(String assetGroup, String targetType); Map<String, Long> getCertificates(String assetGroup); @SuppressWarnings("rawtypes") List<Map<String, Object>> getRecommendations(String assetGroup, String targetType); Long getTotalAssetCountForAnytargetType(String assetGroup, String targetType); List<Map<String, Object>> getResourceDetailsFromES(String assetGroup, String resourceId); List<LinkedHashMap<String, Object>> getIssueAuditLog(String annotationId, String targetType, int from,
            int size, String searchText); Long getIssueAuditLogCount(String annotationId, String targetType); Map<String, Long> getRulesFromES(String assetGroup); @Override Boolean exemptAndUpdateIssueDetails(IssueResponse issueException); @Override Boolean closeIssuesByRule(RuleDetails ruleDetails); @Override Boolean revokeAndUpdateIssueDetails(String issueId); @Override List<Map<String, Object>> getExemptedIssueDetails(String issueId); @Override List<Map<String, Object>> getOpenIssueDetails(final String issueId); List<Map<String, Object>> getRuleIdWithDisplayNameQuery(String targetType); List<Map<String, Object>> getRuleIDsForTargetType(String targetType); List<Map<String, Object>> getRuleIdDetails(String ruleId); @Override List<Object> getRuleIds(String targetType); @SuppressWarnings("rawtypes") Map<String, Long> getNonCompliancePolicyByEsWithAssetGroup(String assetGroup, String searchText,
            Map<String, String> filters, int from, int size, String targetTypes); String getTargetTypeForAG(String assetGroup, String domain); List<Map<String, Object>> getRulesLastScanDate(); String getScanDate(String ruleId, Map<String, String> rulidwithScanDate); String getRuleCategory(Object ruleId, Map<String, String> ruleIdwithruleParamsMap); JsonArray getRuleDetailsByApplicationFromES(String assetGroup, String ruleId, String searchText); Map<String, Long> getAllApplicationsAssetCountForTargetType(String assetGroup, String targetType); List<Map<String, Object>> getTargetTypeByRuleId(String ruleId); Long getTotalAssetCountForEnvironment(String assetGroup, String application, String environment,
            String targetType); JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application,
            String searchText,String targetType); JsonArray getEventsProcessedFromEs(); List<Map<String, Object>> getRuleDescriptionFromDb(String ruleId); List<Map<String, Object>> getKernelComplianceByInstanceIdFromDb(String instanceId); String fetchSystemConfiguration(final String keyname); @SuppressWarnings("unchecked") @Override Map<String, Object> updateKernelVersion(final KernelVersion kernelVersion); Map<String, Object> getRuleCategoryWeightagefromDB(String domain); @SuppressWarnings("rawtypes") Map<String, Object> getTaggingByAG(String assetGroup, String targetTypes, String application); @SuppressWarnings("rawtypes") Map<String, Object> getPolicyViolationDetailsByIssueId(String assetGroup, String issueId); Map<String, Long> getPatchableAssetsByApplication(String assetGroup, String application, String resourceType); List<Map<String, Object>> getRuleIdWithDisplayNameWithRuleCategoryQuery(String targetType,
            String ruleCategory); Long getPatchabeAssetsCount(String assetGroup, String targetType); Long getUnpatchedAssetsCount(String assetGroup, String targetType, String application); Map<String, Object> formatUnpatchedMustFilter(String targetType, String ruleId); Map<String, Long> getRulesDistribution(String assetGroup, String domain, List<Object> rules,
            String aggsFiltername); Map<String, Object> getRuleCategoryPercentage(Map<String, Long> ruleCategoryDistribution, Long totalIssues); Long getInstanceCountForQualys(String assetGroup, String apiType, String application, String environment,
			String resourceType); Map<String, Long> getInstanceCountForQualysByAppsOrEnv(String assetGroup, String apiType, String application,
			String environment, String resourceType); @Override IssueExceptionResponse exemptAndUpdateMultipleIssueDetails(IssuesException issuesException); @Override IssueExceptionResponse revokeAndUpdateMultipleIssueDetails(List<String> issueIds); String createESDoc(Map<String, ?> doc); Response invokeAPI(String method, String endpoint, String payLoad); Map<String,Long> getTotalAssetCountByEnvironment(String assetGroup, String application,String targetType); List<Map<String, String>> getDataSourceForTargetTypeForAG(String assetGroup, String domain,
			String targetType); Map<String, Long> getTotalAssetCount(String assetGroup, String domain, String application, String type); @Override Map<String, Integer> getExemptedAssetsCountByRule(String assetGroup, String application, String type); Long getPatchabeAssetsCount(String assetGroup, String targetType, String application, String environment,
			String searchText); }
ComplianceRepositoryImpl implements ComplianceRepository, Constants { public JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application, String searchText,String targetType) throws DataException { String responseJson = null; JsonParser jsonParser; JsonObject resultJson; StringBuilder requestBody = null; StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append(assetGroup).append("/") .append(SEARCH); if (ruleId.contains(TAGGIG_POLICY)) { List<String> tagsList = new ArrayList<>(Arrays.asList(mandatoryTags.split(","))); String body = "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\""+ruleId+"\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}"; char ch='"'; targetType = ch+targetType+ch; body = body + ",{\"terms\":{\"targetType.keyword\":["+targetType+"]}}"; if(application!=null){ body = body + ",{\"match\":{\"tags.Application.keyword\":\""+application+"\"}}"; } body = body + "]"; if (!tagsList.isEmpty()) { body = body + ",\"should\":["; for (String tag : tagsList) { body = body + "{\"match_phrase_prefix\":{\"missingTags\":\"" + tag + "\"}},"; } body = body.substring(0, body.length() - 1); body = body + "]"; body = body + ",\"minimum_should_match\":1"; } body = body + "}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000000}}}}"; requestBody = new StringBuilder(body); }else{ if (StringUtils.isEmpty(searchText)) { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } else { requestBody = new StringBuilder( "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"ruleId.keyword\":{\"value\":\"" + ruleId + "\"}}},{\"term\":{\"tags.Application.keyword\":{\"value\":\"" + application + "\"}}},{\"match_phrase_prefix\":{\"_all\":\"" + searchText + "\"}}],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"exempted\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"tags.Environment.keyword\",\"size\":1000}}}}"); } } try { responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString()); } catch (Exception e) { logger.error(ERROR_IN_US, e); throw new DataException(e); } jsonParser = new JsonParser(); resultJson = (JsonObject) jsonParser.parse(responseJson); JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(AGGREGATIONS).toString()); return aggsJson.getAsJsonObject("NAME").getAsJsonArray(BUCKETS); }  long getIssuesCount(String assetGroup, String ruleId, String domain); @SuppressWarnings("rawtypes") ResponseWithOrder getIssuesFromES(Request request); @SuppressWarnings("rawtypes") Map<String, Long> getTagging(String assetGroup, String targetType); Map<String, Long> getCertificates(String assetGroup); @SuppressWarnings("rawtypes") List<Map<String, Object>> getRecommendations(String assetGroup, String targetType); Long getTotalAssetCountForAnytargetType(String assetGroup, String targetType); List<Map<String, Object>> getResourceDetailsFromES(String assetGroup, String resourceId); List<LinkedHashMap<String, Object>> getIssueAuditLog(String annotationId, String targetType, int from,
            int size, String searchText); Long getIssueAuditLogCount(String annotationId, String targetType); Map<String, Long> getRulesFromES(String assetGroup); @Override Boolean exemptAndUpdateIssueDetails(IssueResponse issueException); @Override Boolean closeIssuesByRule(RuleDetails ruleDetails); @Override Boolean revokeAndUpdateIssueDetails(String issueId); @Override List<Map<String, Object>> getExemptedIssueDetails(String issueId); @Override List<Map<String, Object>> getOpenIssueDetails(final String issueId); List<Map<String, Object>> getRuleIdWithDisplayNameQuery(String targetType); List<Map<String, Object>> getRuleIDsForTargetType(String targetType); List<Map<String, Object>> getRuleIdDetails(String ruleId); @Override List<Object> getRuleIds(String targetType); @SuppressWarnings("rawtypes") Map<String, Long> getNonCompliancePolicyByEsWithAssetGroup(String assetGroup, String searchText,
            Map<String, String> filters, int from, int size, String targetTypes); String getTargetTypeForAG(String assetGroup, String domain); List<Map<String, Object>> getRulesLastScanDate(); String getScanDate(String ruleId, Map<String, String> rulidwithScanDate); String getRuleCategory(Object ruleId, Map<String, String> ruleIdwithruleParamsMap); JsonArray getRuleDetailsByApplicationFromES(String assetGroup, String ruleId, String searchText); Map<String, Long> getAllApplicationsAssetCountForTargetType(String assetGroup, String targetType); List<Map<String, Object>> getTargetTypeByRuleId(String ruleId); Long getTotalAssetCountForEnvironment(String assetGroup, String application, String environment,
            String targetType); JsonArray getRuleDetailsByEnvironmentFromES(String assetGroup, String ruleId, String application,
            String searchText,String targetType); JsonArray getEventsProcessedFromEs(); List<Map<String, Object>> getRuleDescriptionFromDb(String ruleId); List<Map<String, Object>> getKernelComplianceByInstanceIdFromDb(String instanceId); String fetchSystemConfiguration(final String keyname); @SuppressWarnings("unchecked") @Override Map<String, Object> updateKernelVersion(final KernelVersion kernelVersion); Map<String, Object> getRuleCategoryWeightagefromDB(String domain); @SuppressWarnings("rawtypes") Map<String, Object> getTaggingByAG(String assetGroup, String targetTypes, String application); @SuppressWarnings("rawtypes") Map<String, Object> getPolicyViolationDetailsByIssueId(String assetGroup, String issueId); Map<String, Long> getPatchableAssetsByApplication(String assetGroup, String application, String resourceType); List<Map<String, Object>> getRuleIdWithDisplayNameWithRuleCategoryQuery(String targetType,
            String ruleCategory); Long getPatchabeAssetsCount(String assetGroup, String targetType); Long getUnpatchedAssetsCount(String assetGroup, String targetType, String application); Map<String, Object> formatUnpatchedMustFilter(String targetType, String ruleId); Map<String, Long> getRulesDistribution(String assetGroup, String domain, List<Object> rules,
            String aggsFiltername); Map<String, Object> getRuleCategoryPercentage(Map<String, Long> ruleCategoryDistribution, Long totalIssues); Long getInstanceCountForQualys(String assetGroup, String apiType, String application, String environment,
			String resourceType); Map<String, Long> getInstanceCountForQualysByAppsOrEnv(String assetGroup, String apiType, String application,
			String environment, String resourceType); @Override IssueExceptionResponse exemptAndUpdateMultipleIssueDetails(IssuesException issuesException); @Override IssueExceptionResponse revokeAndUpdateMultipleIssueDetails(List<String> issueIds); String createESDoc(Map<String, ?> doc); Response invokeAPI(String method, String endpoint, String payLoad); Map<String,Long> getTotalAssetCountByEnvironment(String assetGroup, String application,String targetType); List<Map<String, String>> getDataSourceForTargetTypeForAG(String assetGroup, String domain,
			String targetType); Map<String, Long> getTotalAssetCount(String assetGroup, String domain, String application, String type); @Override Map<String, Integer> getExemptedAssetsCountByRule(String assetGroup, String application, String type); Long getPatchabeAssetsCount(String assetGroup, String targetType, String application, String environment,
			String searchText);  }