Search in sources :

Example 1 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue 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;
}
Also used : SonarIssue(com.hp.octane.integrations.services.vulnerabilities.sonar.dto.SonarIssue) DTOFactory(com.hp.octane.integrations.dto.DTOFactory) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

Example 2 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class SSCServiceImpl method getVulnerabilitiesScanResultStream.

@Override
public InputStream getVulnerabilitiesScanResultStream(VulnerabilitiesQueueItem queueItem) {
    try {
        String targetDir = getTargetDir(getConfigurer().pluginServices.getAllowedOctaneStorage(), queueItem.getJobId(), queueItem.getBuildId());
        logger.debug(configurer.octaneConfiguration.getLocationForLog() + "targetDir:" + targetDir);
        InputStream cachedScanResult = getCachedScanResult(targetDir);
        if (cachedScanResult != null) {
            logger.warn(configurer.octaneConfiguration.getLocationForLog() + "Results are cached.");
            return cachedScanResult;
        }
        List<OctaneIssue> octaneIssues = getNonCacheVulnerabilitiesScanResultStream(queueItem);
        logger.debug(configurer.octaneConfiguration.getLocationForLog() + "Done retrieving non-cached.");
        if (octaneIssues == null) {
            return null;
        }
        cacheIssues(targetDir, octaneIssues);
        return IssuesFileSerializer.serializeIssues(octaneIssues);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : InputStream(java.io.InputStream) IOException(java.io.IOException) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

Example 3 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class FODValuesConverter method createIssue.

private OctaneIssue createIssue(Vulnerability vulnerability, String remoteTag, VulnerabilityAllData vulnerabilityAllData, Date baselineDate) {
    OctaneIssue entity = new OctaneIssueImpl();
    entity.setCategory(vulnerability.category);
    if (vulnerability.introducedDate != null) {
        String dateAsString = getIntroducedDate(vulnerability.introducedDate, baselineDate);
        entity.setIntroducedDate(dateAsString);
    }
    setAdditionalData(vulnerability, entity, vulnerabilityAllData);
    entity.setLine(vulnerability.lineNumber);
    entity.setToolName(FODConstants.FODTool);
    entity.setPackage(vulnerability.packageValue);
    // entity.setPRid(vulnerability.);
    entity.setPrimaryLocationFull(vulnerability.primaryLocationFull);
    setStatus(entity, vulnerability.status);
    setSeverity(entity, vulnerability.severity);
    entity.setRemoteId(vulnerability.getRemoteId());
    if (vulnerabilityAllData != null) {
        setExternalLink(vulnerability, entity);
    }
    setAssignedUser(entity, vulnerability.assignedUser);
    setAnalysis(entity, vulnerability);
    entity.setRemoteTag(remoteTag);
    // setToolType(entity);
    return entity;
}
Also used : OctaneIssueImpl(com.hp.octane.integrations.dto.securityscans.impl.OctaneIssueImpl) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

Example 4 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class SSCToOctaneIssueUtil method createOctaneIssue.

private static OctaneIssue createOctaneIssue(DTOFactory dtoFactory, Issues.Issue issue, IssueDetails issueDetails) {
    logger.debug("enter createOctaneIssue");
    OctaneIssue octaneIssue = dtoFactory.newDTO(OctaneIssue.class);
    setOctaneAnalysis(dtoFactory, issue, octaneIssue);
    setOctaneSeverity(dtoFactory, issue, octaneIssue);
    setOctaneStatus(issue, octaneIssue);
    Map<String, String> extendedData = prepareExtendedData(issue, issueDetails);
    octaneIssue.setExtendedData(extendedData);
    octaneIssue.setPrimaryLocationFull(issue.fullFileName);
    octaneIssue.setLine(issue.lineNumber);
    octaneIssue.setRemoteId(issue.issueInstanceId);
    octaneIssue.setIntroducedDate(convertDates(issue.foundDate));
    octaneIssue.setExternalLink(issue.hRef);
    octaneIssue.setToolName(EXTERNAL_TOOL_NAME);
    octaneIssue.setCategory(issue.issueName);
    octaneIssue.setPackage(issue.package1);
    logger.debug("exit createOctaneIssue");
    return octaneIssue;
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

Example 5 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class SSCToOctaneIssueUtil method createOctaneIssues.

public static List<OctaneIssue> createOctaneIssues(List<Issues.Issue> issues, String remoteTag, Map<Integer, IssueDetails> issueDetailsById) {
    if (issues == null) {
        return new ArrayList<>();
    }
    logger.warn("SSCToOctane.createOctaneIssues");
    DTOFactory dtoFactory = DTOFactory.getInstance();
    List<OctaneIssue> octaneIssues = new ArrayList<>();
    for (Issues.Issue issue : issues) {
        OctaneIssue octaneIssue = createOctaneIssue(dtoFactory, issue, issueDetailsById.get(issue.id));
        octaneIssues.add(octaneIssue);
        octaneIssue.setRemoteTag(remoteTag);
    }
    return octaneIssues;
}
Also used : Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) DTOFactory(com.hp.octane.integrations.dto.DTOFactory) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

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