use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.
the class VulnerabilitiesTests method analysisSSCToOctaneWellTransformed.
@Test
public void analysisSSCToOctaneWellTransformed() {
Issues sscIssues = new Issues();
Issues.Issue issue1 = new Issues.Issue();
issue1.reviewed = true;
Issues.Issue issue2 = new Issues.Issue();
issue2.audited = true;
Issues.Issue issue3 = new Issues.Issue();
issue3.issueStatus = "reviewed";
Issues.Issue issue4 = new Issues.Issue();
sscIssues.setData(Arrays.asList(issue1, issue2, issue3, issue4));
SSCHandler sscHandler = new SSCHandler();
List<OctaneIssue> octaneIssues = createOctaneIssues(sscIssues.getData(), "Tag", new HashMap<>());
for (int i = 0; i < 4; i++) {
if (i != 3) {
Assert.assertEquals("list_node.issue_analysis_node.reviewed", octaneIssues.get(i).getAnalysis().getId());
} else {
Assert.assertNull(octaneIssues.get(i).getAnalysis());
}
}
}
use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.
the class VulnerabilitiesTests method stateOctaneWellTransformed.
@Test
public void stateOctaneWellTransformed() {
Issues.Issue issue1 = new Issues.Issue();
issue1.scanStatus = "UPDATED";
Issues.Issue issue2 = new Issues.Issue();
issue2.scanStatus = "NEW";
Issues.Issue issue3 = new Issues.Issue();
issue3.scanStatus = "REINTRODUCED";
Issues.Issue issue4 = new Issues.Issue();
issue4.scanStatus = "REMOVED";
Issues.Issue issue5 = new Issues.Issue();
Issues sscIssues = new Issues();
sscIssues.setData(Arrays.asList(issue1, issue2, issue3, issue4, issue5));
SSCHandler sscHandler = new SSCHandler();
List<OctaneIssue> octaneIssues = createOctaneIssues(sscIssues.getData(), "Tag", new HashMap<>());
String[] expectedValues = new String[] { "list_node.issue_state_node.existing", "list_node.issue_state_node.new", "list_node.issue_state_node.reopen", "list_node.issue_state_node.closed" };
for (int i = 0; i < 5; i++) {
if (i != 4) {
Assert.assertEquals(expectedValues[i], octaneIssues.get(i).getState().getId());
} else {
Assert.assertNull(octaneIssues.get(i).getState());
}
}
}
use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.
the class FODServiceImpl method fetchIssues.
private List<OctaneIssue> fetchIssues(VulnerabilitiesQueueItem queueItem, String remoteTag) throws IOException {
logger.warn(configurer.octaneConfiguration.getLocationForLog() + "Security scan is done.");
List<Vulnerability> allVulnerabilities = FODVulnerabilityService.getAllVulnerabilities(getRelease(queueItem));
List<Vulnerability> nonClosedIssues = filterOutBeforeBaselineIssues(queueItem.getBaselineDate(), allVulnerabilities);
ExistingIssuesInOctane existingIssuesInOctane = new ExistingIssuesInOctane(this.restService.obtainOctaneRestClient(), this.configurer.octaneConfiguration);
List<String> existingIssuesInOc = existingIssuesInOctane.getRemoteIdsOpenVulnsFromOctane(queueItem.getJobId(), queueItem.getBuildId(), remoteTag);
PackIssuesToOctaneUtils.SortedIssues<Vulnerability> sortedIssues = PackIssuesToOctaneUtils.packToOctaneIssues(nonClosedIssues, existingIssuesInOc, true);
FODValuesConverter securityIssueValuesHelper = new FODValuesConverter();
securityIssueValuesHelper.init();
Map<String, VulnerabilityAllData> idToAllData = getVulnerabilityAllDataMap(getRelease(queueItem), sortedIssues.issuesRequiredExtendedData);
logger.warn(configurer.octaneConfiguration.getLocationForLog() + "fetch existing issues from Octane");
List<OctaneIssue> octaneIssuesToUpdate = securityIssueValuesHelper.createOctaneIssuesFromVulns(sortedIssues.issuesToUpdate, remoteTag, idToAllData, queueItem.getBaselineDate());
List<OctaneIssue> total = new ArrayList<>();
total.addAll(octaneIssuesToUpdate);
logger.warn(configurer.octaneConfiguration.getLocationForLog() + "ToUpdate " + octaneIssuesToUpdate.size() + " items : " + octaneIssuesToUpdate);
total.addAll(sortedIssues.issuesToClose);
logger.warn(configurer.octaneConfiguration.getLocationForLog() + "ToClose " + sortedIssues.issuesToClose.size() + " items : " + sortedIssues.issuesToClose);
return total;
}
use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.
the class SonarToOctaneIssueUtil method createOctaneIssue.
private static OctaneIssue createOctaneIssue(DTOFactory dtoFactory, SonarIssue issue, Map<String, SonarRule> rules, String sonarUrl) {
logger.debug("enter createOctaneIssue");
OctaneIssue octaneIssue = dtoFactory.newDTO(OctaneIssue.class);
setOctaneSeverity(issue, octaneIssue);
setPrimaryLocationFull(issue, octaneIssue);
setExternalLink(issue, octaneIssue, sonarUrl);
octaneIssue.setLine(issue.getLine());
octaneIssue.setRemoteId(issue.getKey());
octaneIssue.setIntroducedDate(convertDates(issue.getCreationDate()));
octaneIssue.setToolName(EXTERNAL_TOOL_NAME);
octaneIssue.setCategory(rules.get(issue.getRule()).getName());
logger.debug("exit createOctaneIssue");
return octaneIssue;
}
use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.
the class SSCServiceImpl method getNonCacheVulnerabilitiesScanResultStream.
private List<OctaneIssue> getNonCacheVulnerabilitiesScanResultStream(VulnerabilitiesQueueItem queueItem) throws IOException {
SSCProjectConfiguration sscProjectConfiguration = configurer.pluginServices.getSSCProjectConfiguration(queueItem.getJobId(), queueItem.getBuildId());
if (sscProjectConfiguration == null || !sscProjectConfiguration.isValid()) {
logger.error(configurer.octaneConfiguration.getLocationForLog() + "cannot retrieve SSC Project CFG.");
logger.debug(configurer.octaneConfiguration.getLocationForLog() + "SSC project configurations is missing or not valid, skipping processing for " + queueItem.getJobId() + " #" + queueItem.getBuildId());
return null;
}
SSCHandler sscHandler = new SSCHandler(queueItem, sscProjectConfiguration, this.restService.obtainSSCRestClient());
logger.debug(configurer.octaneConfiguration.getLocationForLog() + "retrieve issues from SSC");
List<Issues.Issue> issuesFromSecurityTool = getIssuesFromSSC(sscHandler, queueItem);
if (issuesFromSecurityTool == null) {
return null;
}
logger.debug(configurer.octaneConfiguration.getLocationForLog() + "retrieve octane remote ids");
List<String> octaneExistsIssuesIdsList = getRemoteIdsOfExistIssuesFromOctane(queueItem, sscProjectConfiguration.getRemoteTag());
logger.debug(configurer.octaneConfiguration.getLocationForLog() + "done retrieveing octane remote ids");
PackSSCIssuesToSendToOctane packSSCIssuesToSendToOctane = new PackSSCIssuesToSendToOctane();
packSSCIssuesToSendToOctane.setConsiderMissing(queueItem.getBaselineDate() != null);
packSSCIssuesToSendToOctane.setOctaneIssues(octaneExistsIssuesIdsList);
packSSCIssuesToSendToOctane.setRemoteTag(sscProjectConfiguration.getRemoteTag());
packSSCIssuesToSendToOctane.setSscHandler(sscHandler);
packSSCIssuesToSendToOctane.setSscIssues(issuesFromSecurityTool);
return packSSCIssuesToSendToOctane.packToOctaneIssues();
}
Aggregations