Search in sources :

Example 21 with CheckmarxException

use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxService method getReportContentByScanId.

/**
 * Retrieve the report by reportId, mapped to ScanResults DTO, applying filtering as requested
 */
public ScanResults getReportContentByScanId(Integer scanId, FilterConfiguration filter) throws CheckmarxException {
    Integer reportId = createScanReport(scanId);
    try {
        waitForReportCreateOrFail(reportId);
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        log.error(ExceptionUtils.getStackTrace(e));
        Thread.currentThread().interrupt();
        throw new CheckmarxException(INTERRUPTED_EXCEPTION_MESSAGE);
    }
    return getReportContent(reportId, filter);
}
Also used : CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException)

Example 22 with CheckmarxException

use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxService method getLatestScanResults.

/**
 * Get the latest scan results by teamName and projectName with filtered results
 *
 * @param teamName
 * @param projectName
 * @param filters
 * @return
 * @throws CheckmarxException
 */
@Override
public ScanResults getLatestScanResults(String teamName, String projectName, FilterConfiguration filters) throws CheckmarxException {
    String teamId = getTeamId(teamName);
    Integer projectId = getProjectId(teamId, projectName);
    Integer scanId = getLastScanId(projectId);
    try {
        Integer reportId = createScanReport(scanId);
        waitForReportCreateOrFail(reportId);
        Thread.sleep(cxProperties.getScanPolling());
        return getReportContent(reportId, filters);
    } catch (InterruptedException e) {
        log.error(ExceptionUtils.getStackTrace(e));
        Thread.currentThread().interrupt();
        throw new CheckmarxException(INTERRUPTED_EXCEPTION_MESSAGE);
    }
}
Also used : CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException)

Example 23 with CheckmarxException

use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxServiceIT method getReportContent.

@Test
public void getReportContent() {
    try {
        List<Filter> filters = new ArrayList<>();
        filters.add(new Filter(Filter.Type.SEVERITY, "High"));
        FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(filters);
        ScanResults results = service.getLatestScanResults(properties.getTeam(), "Riches", filterConfiguration);
        assertNotNull(results);
    } catch (CheckmarxException e) {
        fail("Unexpected CheckmarxException");
    }
}
Also used : Filter(com.checkmarx.sdk.dto.sast.Filter) ScanResults(com.checkmarx.sdk.dto.ScanResults) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) ArrayList(java.util.ArrayList) FilterConfiguration(com.checkmarx.sdk.dto.filtering.FilterConfiguration) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with CheckmarxException

use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxServiceIT method getScanSummary.

@Test
public void getScanSummary() {
    try {
        String teamId = service.getTeamId(properties.getTeam());
        Integer projectId = service.getProjectId(teamId, "Riches");
        CxScanSummary summary = service.getScanSummary(projectId);
        assertNotNull(summary);
        assertNotNull(summary.getStatisticsCalculationDate());
    } catch (CheckmarxException e) {
        fail("Unexpected CheckmarxException");
    }
}
Also used : CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) CxScanSummary(com.checkmarx.sdk.dto.cx.CxScanSummary) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with CheckmarxException

use of com.checkmarx.sdk.exception.CheckmarxException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxServiceIT method getXmlReportContent.

@Test
public void getXmlReportContent() {
    try {
        CxXMLResultsType results = service.getLatestScanReport(properties.getTeam(), "Riches");
        assertNotNull(results);
    } catch (CheckmarxException e) {
        fail("Unexpected CheckmarxException");
    }
}
Also used : CxXMLResultsType(com.checkmarx.sdk.dto.cx.xml.CxXMLResultsType) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)62 HttpStatusCodeException (org.springframework.web.client.HttpStatusCodeException)23 ScanResults (com.checkmarx.sdk.dto.ScanResults)11 HttpEntity (org.springframework.http.HttpEntity)10 MachinaException (com.checkmarx.flow.exception.MachinaException)8 Test (org.junit.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 File (java.io.File)6 JSONObject (org.json.JSONObject)6 CxProject (com.checkmarx.sdk.dto.cx.CxProject)5 CxScanParams (com.checkmarx.sdk.dto.cx.CxScanParams)4 IOException (java.io.IOException)4 JAXBContext (javax.xml.bind.JAXBContext)4 JAXBException (javax.xml.bind.JAXBException)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 XMLInputFactory (javax.xml.stream.XMLInputFactory)3 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)3 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)3 SoapActionCallback (org.springframework.ws.soap.client.core.SoapActionCallback)3 ScanReport (com.checkmarx.flow.dto.report.ScanReport)2