Search in sources :

Example 21 with ScanRequest

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

the class RunPublishProcessSteps method publishResults.

@When("publishing results to JIRA")
public void publishResults() throws ExitThrowable, IOException {
    ScanRequest request = getScanRequestWithDefaults();
    if (needFilter) {
        request.setFilter(FilterConfiguration.fromSimpleFilters(filters));
    }
    File file = getFileForPublish();
    innerPublishRequest(request, file);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) File(java.io.File) When(io.cucumber.java.en.When)

Example 22 with ScanRequest

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

the class GetResultsAnalyticsTestSteps method createScanRequest.

private ScanRequest createScanRequest() {
    ScanRequest scanRequest = new ScanRequest();
    BugTracker issueTracker = BugTracker.builder().type(BugTracker.Type.NONE).build();
    scanRequest.setBugTracker(issueTracker);
    scanRequest.setMergeNoteUri(MERGE_NOTE_URL);
    scanRequest.setProduct(ScanRequest.Product.CX);
    Map<String, String> additionalMetaData = new HashMap<>();
    additionalMetaData.put("statuses_url", PULL_REQUEST_STATUSES_URL);
    scanRequest.setAdditionalMetadata(additionalMetaData);
    return scanRequest;
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) BugTracker(com.checkmarx.flow.dto.BugTracker)

Example 23 with ScanRequest

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

the class FlowControllerTest method testScanApiWithDefaultParamters.

@Test
public void testScanApiWithDefaultParamters() {
    FlowController.CxScanRequest request = getScanRequestWithDefaults();
    FlowController.CxScanRequest referenceRequest = getScanRequestWithDefaults();
    referenceRequest.setFilters(getDefaultFilters());
    ArgumentCaptor<ScanRequest> captor = ArgumentCaptor.forClass(ScanRequest.class);
    ResponseEntity<EventResponse> response = flowController.initiateScan(request, flowProperties.getToken());
    verify(flowService).initiateAutomation(captor.capture());
    ScanRequest actual = captor.getValue();
    assertScanRequest(actual, referenceRequest);
    assertOKResponse(response);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) EventResponse(com.checkmarx.flow.dto.EventResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 24 with ScanRequest

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

the class FlowControllerTest method testScanApiWithFilters.

@ParameterizedTest
@MethodSource("generateDataForScanApi")
public void testScanApiWithFilters(String filterSeverity, String filterCwe, String filterOwasp, String filterType, String filterStatus, String id) {
    FlowController.CxScanRequest request = getScanRequestWithDefaults();
    List<Filter> filters = prepareScanApiFilters(filterSeverity, filterCwe, filterOwasp, filterType, filterStatus);
    request.setFilters(filters);
    ResponseEntity<EventResponse> response = flowController.initiateScan(request, flowProperties.getToken());
    ArgumentCaptor<ScanRequest> captor = ArgumentCaptor.forClass(ScanRequest.class);
    verify(flowService).initiateAutomation(captor.capture());
    ScanRequest actual = captor.getValue();
    assertScanApiFilters(actual.getFilter().getSastFilters().getSimpleFilters(), filters);
    assertOKResponse(response);
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) EventResponse(com.checkmarx.flow.dto.EventResponse) Filter(com.checkmarx.sdk.dto.sast.Filter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 25 with ScanRequest

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

the class GitHubCommentsASTSteps method createScanRequest.

private ScanRequest createScanRequest() {
    ScanRequest scanRequest = new ScanRequest();
    scanRequest.setMergeNoteUri(MERGE_NOTE_URL);
    scanRequest.setProduct(ScanRequest.Product.CX);
    Map<String, String> additionalMetaData = new HashMap<>();
    additionalMetaData.put("statuses_url", PULL_REQUEST_STATUSES_URL);
    scanRequest.setAdditionalMetadata(additionalMetaData);
    if (repo.equals(ScanRequest.Repository.GITHUB)) {
        scanRequest.setRepoType(ScanRequest.Repository.GITHUB);
        BugTracker issueTracker = BugTracker.builder().type(BugTracker.Type.GITHUBPULL).build();
        scanRequest.setBugTracker(issueTracker);
    } else {
        throw new UnsupportedOperationException();
    }
    return scanRequest;
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) BugTracker(com.checkmarx.flow.dto.BugTracker)

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