Search in sources :

Example 11 with OctaneIssue

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());
        }
    }
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Example 12 with OctaneIssue

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());
        }
    }
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Example 13 with OctaneIssue

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;
}
Also used : ExistingIssuesInOctane(com.hp.octane.integrations.services.vulnerabilities.ExistingIssuesInOctane) Vulnerability(com.hp.octane.integrations.services.vulnerabilities.fod.dto.pojos.Vulnerability) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) PackIssuesToOctaneUtils(com.hp.octane.integrations.services.vulnerabilities.PackIssuesToOctaneUtils) VulnerabilityAllData(com.hp.octane.integrations.services.vulnerabilities.fod.dto.pojos.VulnerabilityAllData)

Example 14 with OctaneIssue

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;
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

Example 15 with 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();
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) SSCProjectConfiguration(com.hp.octane.integrations.dto.securityscans.SSCProjectConfiguration)

Aggregations

OctaneIssue (com.hp.octane.integrations.dto.securityscans.OctaneIssue)15 Issues (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues)7 SSCToOctaneIssueUtil.createOctaneIssues (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues)6 Test (org.junit.Test)6 SSCHandler (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler)4 DTOFactory (com.hp.octane.integrations.dto.DTOFactory)2 IOException (java.io.IOException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SSCProjectConfiguration (com.hp.octane.integrations.dto.securityscans.SSCProjectConfiguration)1 OctaneIssueImpl (com.hp.octane.integrations.dto.securityscans.impl.OctaneIssueImpl)1 ExistingIssuesInOctane (com.hp.octane.integrations.services.vulnerabilities.ExistingIssuesInOctane)1 PackIssuesToOctaneUtils (com.hp.octane.integrations.services.vulnerabilities.PackIssuesToOctaneUtils)1 Vulnerability (com.hp.octane.integrations.services.vulnerabilities.fod.dto.pojos.Vulnerability)1 VulnerabilityAllData (com.hp.octane.integrations.services.vulnerabilities.fod.dto.pojos.VulnerabilityAllData)1 SonarIssue (com.hp.octane.integrations.services.vulnerabilities.sonar.dto.SonarIssue)1 IssueDetails (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.IssueDetails)1 InputStream (java.io.InputStream)1 StringWriter (java.io.StringWriter)1