use of com.hp.octane.integrations.services.vulnerabilities.sonar.dto.SonarIssue in project octane-ci-java-sdk by MicroFocus.
the class SonarToOctaneIssueUtil method createOctaneIssues.
public static List<OctaneIssue> createOctaneIssues(List<SonarIssue> issues, String remoteTag, String sonarUrl, Set<String> issuesRequiredExtendedDataKeys, Map<String, SonarRule> rules) {
if (issues == null) {
return new ArrayList<>();
}
DTOFactory dtoFactory = DTOFactory.getInstance();
List<OctaneIssue> octaneIssues = new ArrayList<>();
for (SonarIssue issue : issues) {
OctaneIssue octaneIssue = createOctaneIssue(dtoFactory, issue, rules, sonarUrl);
octaneIssue.setRemoteTag(remoteTag);
octaneIssues.add(octaneIssue);
if (issuesRequiredExtendedDataKeys.contains(issue.getKey())) {
Map<String, String> extendedData = prepareExtendedData(issue, rules);
octaneIssue.setExtendedData(extendedData);
setOctaneStatus(issue, octaneIssue, true);
} else {
setOctaneStatus(issue, octaneIssue, false);
}
}
return octaneIssues;
}
use of com.hp.octane.integrations.services.vulnerabilities.sonar.dto.SonarIssue in project octane-ci-java-sdk by MicroFocus.
the class SonarVulnerabilitiesServiceImpl method getIssuesFromSecurityTool.
public List<SonarIssue> getIssuesFromSecurityTool(VulnerabilitiesQueueItem queueItem) {
String projectKey = queueItem.getAdditionalProperties().get(PROJECT_KEY_KEY);
String sonarToken = queueItem.getAdditionalProperties().get(SONAR_TOKEN_KEY);
StringBuilder errorMessage = new StringBuilder().append("failed to get sonarqube vulnerability data for project key: ").append(projectKey).append(" with jobId: ").append(queueItem.getJobId()).append(" with buildId: ").append(queueItem.getBuildId());
try {
List<SonarIssue> sonarIssues = new ArrayList<>();
// retrieve coverage report from Sonar
Integer pageIndex = 0;
JsonNode jsonReport;
do {
pageIndex++;
URIBuilder vulnerabilityQuery = createQueryForSonarVulnerability(pageIndex, queueItem);
InputStream reportStream = SonarUtils.getDataFromSonar(projectKey, sonarToken, vulnerabilityQuery);
jsonReport = CIPluginSDKUtils.getObjectMapper().readTree(reportStream);
sonarIssues.addAll(getSonarIssuesFromReport(jsonReport));
} while (SonarUtils.sonarReportHasAnotherPage(pageIndex, jsonReport));
return sonarIssues;
} catch (IOException e) {
logger.error(errorMessage, e);
throw new PermanentException(e);
}
}
use of com.hp.octane.integrations.services.vulnerabilities.sonar.dto.SonarIssue in project octane-ci-java-sdk by MicroFocus.
the class SonarVulnerabilitiesServiceImpl method getSonarIssuesFromReport.
public List<SonarIssue> getSonarIssuesFromReport(JsonNode jsonReport) {
List<SonarIssue> sonarIssues;
JsonNode issues = jsonReport.get("issues");
try {
sonarIssues = mapper.readValue(issues.toString(), new TypeReference<List<SonarIssue>>() {
});
} catch (IOException e) {
throw new RuntimeException(e);
}
return sonarIssues;
}
Aggregations