Search in sources :

Example 61 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class AbstractScanSteps method generateRequest.

private ScanRequest generateRequest() {
    ScanRequest request = ScanRequest.builder().application(this.application).product(this.product).project(this.projectName).team(this.teamName).namespace(this.namespace).repoName(this.repoName).repoUrl(this.repoUrl).repoUrlWithAuth(this.gitAuthUrl).repoType(repoType).branch(this.branch).refs(Constants.CX_BRANCH_PREFIX.concat(this.branch)).mergeNoteUri(null).mergeTargetBranch(null).email(null).incremental(false).scanPreset(this.preset).bugTracker(BugTracker.builder().type(BugTracker.Type.CUSTOM).customBean("").build()).build();
    cxProperties.setScanTimeout(1800);
    cxProperties.setConfiguration("Default Configuration");
    if (!filters.isEmpty()) {
        request.setFilter(FilterConfiguration.fromSimpleFilters(filters));
    }
    if (!excludeFilesList.isEmpty()) {
        request.setExcludeFiles(excludeFilesList);
    }
    if (!excludeFoldersList.isEmpty()) {
        request.setExcludeFolders(excludeFoldersList);
    }
    if (cxProperties.getIncremental()) {
        request.setIncremental(true);
    }
    return request;
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest)

Example 62 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class SarifIssueTrackerTest method completeWithParameters.

@Test
public void completeWithParameters() {
    SarifIssueTracker issueTracker = getInstance();
    try {
        ScanRequest request = getRequest();
        ScanResults results = getResults();
        request.setFilename("./sarif-result.json");
        issueTracker.complete(request, results);
        assert true;
    } catch (MachinaException e) {
        assert false;
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) Test(org.junit.Test)

Example 63 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class ServiceNowTrackerTest method searchAndCloseIssues_WithAllParams_Success.

@Test
public void searchAndCloseIssues_WithAllParams_Success() {
    try {
        log.info("Start searchAndCloseIssues_WithAllParams_Success");
        // find an existing issue
        ScanRequest request = getRequest();
        List<Issue> issues = issueTracker.getIssues(request);
        assertNotNull(issues);
        assertTrue(issues.size() > 0);
        assertNotNull(issues.get(0).getId());
        request.setId(issues.get(0).getId());
        // close an existing issue
        issueTracker.closeIssue(issues.get(0), request);
        // check closed issue
        issues = issueTracker.getIssues(request);
        assertNotNull(issues);
        assertTrue(issues.size() > 0);
        assertTrue(issues.get(0).getState().equals("7"));
    } catch (MachinaException e) {
        log.error(e.getMessage());
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) Issue(com.checkmarx.flow.dto.Issue) MachinaException(com.checkmarx.flow.exception.MachinaException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 64 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class ServiceNowTrackerTest method searchAndUpdateIssues_WithAllParams_Success.

@Test
public void searchAndUpdateIssues_WithAllParams_Success() {
    try {
        log.info("Start searchAndUpdateIssues_WithAllParams_Success");
        // find an existing issue
        ScanRequest request = getRequest();
        List<Issue> issues = issueTracker.getIssues(request);
        assertNotNull(issues);
        assertTrue(issues.size() > 0);
        assertNotNull(issues.get(0).getId());
        ScanResults.XIssue resultIssue = getIssue("update test incident");
        request.setId(issues.get(0).getId());
        // update existing issue
        Issue upatedIssue = issueTracker.updateIssue(issues.get(0), resultIssue, request);
        assertNotNull(upatedIssue);
    } catch (MachinaException e) {
        log.error(e.getMessage());
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) Issue(com.checkmarx.flow.dto.Issue) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 65 with ScanRequest

use of com.checkmarx.flow.dto.ScanRequest in project cx-flow by checkmarx-ltd.

the class ServiceNowTrackerTest method createAndSearchIssues_WithAllParams_Success.

@Test
public void createAndSearchIssues_WithAllParams_Success() {
    try {
        log.info("Start createAndSearchIssues_WithAllParams_Success");
        ScanResults.XIssue issue = getIssue("create test incident");
        ScanRequest request = getRequest();
        issueTracker.init(request, null);
        Issue newIssue = issueTracker.createIssue(issue, request);
        assertNotNull(newIssue);
    } catch (MachinaException e) {
        log.error(e.getMessage());
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) Issue(com.checkmarx.flow.dto.Issue) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ScanRequest (com.checkmarx.flow.dto.ScanRequest)68 BugTracker (com.checkmarx.flow.dto.BugTracker)24 ScanResults (com.checkmarx.sdk.dto.ScanResults)20 When (io.cucumber.java.en.When)14 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)12 MachinaException (com.checkmarx.flow.exception.MachinaException)11 CxConfig (com.checkmarx.sdk.dto.sast.CxConfig)11 Test (org.junit.Test)11 File (java.io.File)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Issue (com.checkmarx.flow.dto.Issue)5 MachinaRuntimeException (com.checkmarx.flow.exception.MachinaRuntimeException)5 IOException (java.io.IOException)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 IfProfileValue (org.springframework.test.annotation.IfProfileValue)4 EventResponse (com.checkmarx.flow.dto.EventResponse)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 FlowProperties (com.checkmarx.flow.config.FlowProperties)2