Search in sources :

Example 56 with CheckmarxException

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

the class CxLegacyService method createTeam.

void createTeam(String sessionId, String parentId, String teamName) throws CheckmarxException {
    CreateNewTeam request = new CreateNewTeam(sessionId);
    request.setNewTeamName(teamName);
    request.setParentTeamID(parentId);
    log.info("Creating team {} ({})", teamName, parentId);
    // If shards are enabled then fetch the current shard info for override.
    WebServiceTemplate wsInstance = ws;
    if (properties.getEnableShardManager()) {
        ShardSession shard = sessionTracker.getShardSession();
        wsInstance = shard.getShardWs();
    }
    try {
        CreateNewTeamResponse response = (CreateNewTeamResponse) wsInstance.marshalSendAndReceive(wsInstance.getDefaultUri(), request, new SoapActionCallback(CX_WS_CREATE_TEAM_URI));
        if (!response.getCreateNewTeamResult().isIsSuccesfull()) {
            log.error("Error occurred while creating Team {} with parentId {}", teamName, parentId);
            throw new CheckmarxException("Error occurred during team creation");
        }
    } catch (NullPointerException e) {
        log.error("Error occurred while creating Team {} with parentId {}", teamName, parentId);
        throw new CheckmarxException("Error occurred during team creation");
    }
}
Also used : SoapActionCallback(org.springframework.ws.soap.client.core.SoapActionCallback) ShardSession(com.checkmarx.sdk.ShardManager.ShardSession) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate)

Example 57 with CheckmarxException

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

the class CxServiceIT method createScan.

@Test
public void createScan() {
    log.info("Creating scan");
    login();
    try {
        CxScanParams params = new CxScanParams().withSourceType(CxScanParams.Type.GIT).withGitUrl("https://github.com/Custodela/Riches.git").withBranch("refs/heads/master").withProjectName("CxSBSDK-IT");
        // .withProjectName("Riches");
        // String teamId = service.getTeamId(properties.getTeam());
        Integer id = service.createScan(params, "Automated Comment");
        assertNotNull(id);
        assertTrue(id > 0);
    } catch (CheckmarxException e) {
        fail("Unexpected CheckmarxException");
    }
}
Also used : CxScanParams(com.checkmarx.sdk.dto.cx.CxScanParams) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 58 with CheckmarxException

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

the class CxServiceIT method getProject.

@Test
public void getProject() {
    try {
        String teamId = service.getTeamId(properties.getTeam());
        Integer projectId = service.getProjectId(teamId, "Riches");
        CxProject project = service.getProject(projectId);
        assertNotNull(project);
        assertNotEquals(Integer.valueOf(-1), project.getId());
    } catch (CheckmarxException e) {
        fail("Unexpected CheckmarxException");
    }
}
Also used : CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) CxProject(com.checkmarx.sdk.dto.cx.CxProject) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 59 with CheckmarxException

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

the class CxServiceIT method getLastScanDate.

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

Example 60 with CheckmarxException

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

the class GoScanner method getScanStatusById.

public ScanStatus getScanStatusById(Integer scanId) throws CheckmarxException {
    HttpEntity<?> httpEntity = new HttpEntity<>(authClient.createAuthHeaders());
    try {
        log.debug("Retrieving ScanStatus for Scan Id {}", scanId);
        ResponseEntity<ScanStatus> response = restTemplate.exchange(cxGoProperties.getUrl().concat(SCAN_STATUS), HttpMethod.GET, httpEntity, ScanStatus.class, scanId);
        return response.getBody();
    } catch (HttpStatusCodeException e) {
        log.error("Error occurred while retrieving the scan status for id {}.", scanId);
        log.error(ExceptionUtils.getStackTrace(e));
        throw new CheckmarxException("Error occurred while retrieving the scan status for id ".concat(Integer.toString(scanId)));
    }
}
Also used : HttpEntity(org.springframework.http.HttpEntity) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) HttpStatusCodeException(org.springframework.web.client.HttpStatusCodeException)

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