Search in sources :

Example 26 with ScanRequest

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

the class ThresholdsSteps method createScanRequest.

private ScanRequest createScanRequest(boolean isGitHub) {
    ScanRequest scanRequest = new ScanRequest();
    BugTracker.Type issueTruckerType;
    Map<String, String> additionalMetadata = new HashMap<>();
    additionalMetadata.put(STATUSES_URL_KEY, PULL_REQUEST_STATUSES_URL);
    if (isGitHub) {
        issueTruckerType = BugTracker.Type.GITHUBPULL;
        scanRequest.setMergeNoteUri(MERGE_NOTE_URL);
        scanRequest.setRepoType(ScanRequest.Repository.GITHUB);
    } else {
        issueTruckerType = BugTracker.Type.ADOPULL;
        additionalMetadata.put("status_id", Integer.toString(1));
        additionalMetadata.put("ado_thread_id", Integer.toString(0));
        scanRequest.setRepoType(ScanRequest.Repository.ADO);
        scanRequest.setMergeNoteUri(MERGE_NOTE_URL);
        scanResultsToInject.setProjectId(Integer.toString(0));
    }
    BugTracker issueTracker = BugTracker.builder().type(issueTruckerType).build();
    scanRequest.setBugTracker(issueTracker);
    scanRequest.setProduct(ScanRequest.Product.CX);
    scanRequest.setAdditionalMetadata(additionalMetadata);
    return scanRequest;
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) HashMap(java.util.HashMap) BugTracker(com.checkmarx.flow.dto.BugTracker)

Example 27 with ScanRequest

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

the class ThresholdsSteps method processScanResultsInCxFlow.

private void processScanResultsInCxFlow(boolean isGitHub) {
    try {
        ScanRequest scanRequest = createScanRequest(isGitHub);
        CompletableFuture<ScanResults> task = resultsService.processScanResultsAsync(scanRequest, 0, 0, null, null);
        task.get(1, TimeUnit.MINUTES);
    } catch (MachinaException | InterruptedException | ExecutionException | TimeoutException e) {
        String message = "Error processing scan results.";
        log.error(message, e);
        Assert.fail(message);
        Thread.currentThread().interrupt();
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 28 with ScanRequest

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

the class CxConfigBugTrackerSteps method sendPullRequestWebhookEvent.

@When("pull request webhook arrives")
public void sendPullRequestWebhookEvent() {
    assertFlowPropertiesBugTracker("Json");
    ArgumentCaptor<ScanRequest> ac = ArgumentCaptor.forClass(ScanRequest.class);
    FlowService flowServiceMock = Mockito.mock(FlowService.class);
    gitHubControllerSpy = new GitHubController(gitHubProperties, flowProperties, jiraProperties, flowServiceMock, helperService, gitHubService, gitHubAppAuthService, filterFactory, configOverrider, scmConfigOverrider, gitAuthUrlGenerator);
    gitHubControllerSpy = spy(gitHubControllerSpy);
    initGitHubControllerSpy();
    buildPullRequest();
    verify(flowServiceMock, times(1)).initiateAutomation(ac.capture());
    request = ac.getValue();
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) GitHubController(com.checkmarx.flow.controller.GitHubController) When(io.cucumber.java.en.When)

Example 29 with ScanRequest

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

the class AstRemoteRepoScanSteps method getBasicScanRequest.

private ScanRequest getBasicScanRequest(String branch, String gitUrl, boolean isPublicRepo, String projectName) {
    String gitAuthUrl;
    if (isPublicRepo) {
        gitAuthUrl = gitUrl;
    } else {
        gitAuthUrl = gitAuthUrlGenerator.addCredToUrl(ScanRequest.Repository.GITHUB, gitUrl, gitHubProperties.getToken());
    }
    ScanRequest result = ScanRequest.builder().project(projectName).repoUrlWithAuth(gitAuthUrl).branch(branch).repoType(ScanRequest.Repository.GITHUB).build();
    scaConfigOverrider.initScaConfig(result);
    return result;
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest)

Example 30 with ScanRequest

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

the class IastCliSteps method runningIastService.

@SneakyThrows
@When("running iast service {}")
public void runningIastService(String scanTag) {
    scanTag = removeQuotes(scanTag);
    try {
        BugTracker.Type bugType = BugTracker.Type.GITHUBCOMMIT;
        String assignee = "test_user";
        BugTracker bt = BugTracker.builder().type(bugType).assignee(assignee).build();
        ScanRequest request = ScanRequest.builder().bugTracker(bt).build();
        iastService.stopScanAndCreateIssue(request, scanTag);
    } catch (IastThresholdsSeverityException e) {
    // that is ok. Just Thresholds Severity
    }
}
Also used : ScanRequest(com.checkmarx.flow.dto.ScanRequest) IastThresholdsSeverityException(com.checkmarx.flow.exception.IastThresholdsSeverityException) BugTracker(com.checkmarx.flow.dto.BugTracker) When(io.cucumber.java.en.When) SneakyThrows(lombok.SneakyThrows)

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