Search in sources :

Example 46 with ScanResults

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

the class GetResultsAnalyticsTestSteps method getResultsWithFilter.

@When("doing get results operation on SAST scan with {int} {int} {int} {int} results and filter is {string}")
public void getResultsWithFilter(int high, int medium, int low, int info, String filter) throws InterruptedException {
    try {
        scanResultsToInject = createFakeSASTScanResults();
        ScanRequest scanRequest = createScanRequest();
        setFindingsSummary(high, medium, low, info, filter);
        addAdditionalInfoToResults();
        addFlowSummaryToResults(high, medium, low, info);
        CompletableFuture<ScanResults> task = resultsService.processScanResultsAsync(scanRequest, PROJECT_ID, SCAN_ID, null, null);
        task.get(1, TimeUnit.MINUTES);
    } catch (MachinaException | ExecutionException | TimeoutException e) {
        String message = "Error processing scan results.";
        log.error(message, e);
        Assert.fail(message);
    }
}
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) When(io.cucumber.java.en.When)

Example 47 with ScanResults

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

the class DeleteBranchSteps method initMockers.

private void initMockers() throws CheckmarxException {
    ScanResultsAnswerer answerer = new ScanResultsAnswerer();
    doAnswer(answerer).when(cxClientMock).deleteProject(any());
    when(helperService.getShortUid()).thenReturn("12345");
    when(helperService.getCxTeam(any())).thenReturn(TEAM);
    when(helperService.getCxProject(any())).thenCallRealMethod();
    when(helperService.getPresetFromSources(any())).thenReturn(PRESET);
    when(helperService.isBranchProtected(anyString(), anyList(), any())).thenCallRealMethod();
    when(helperService.isBranch2Scan(any(), anyList())).thenCallRealMethod();
    when(cxClientMock.getTeamId(anyString(), anyString())).thenReturn(TEAM);
    when(cxClientMock.getTeamId(anyString())).thenReturn(TEAM);
    when(cxClientMock.getScanIdOfExistingScanIfExists(anyInt())).thenReturn(SCAN_ID_EXISTING_SCAN_NOT_EXIST);
    when(cxClientMock.getReportContentByScanId(anyInt(), any())).thenReturn(new ScanResults());
    when(adoServiceMock.getCxConfigOverride(any(), anyString())).thenReturn(cxConfig);
    when(resultsServiceMock.publishCombinedResults(any(), any())).thenReturn(null);
}
Also used : ScanResults(com.checkmarx.sdk.dto.ScanResults)

Example 48 with ScanResults

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

the class Github2AdoSteps method createFakeResults.

private ScanResults createFakeResults() {
    ScanResults result = new ScanResults();
    result.setScanSummary(new CxScanSummary());
    Map<String, Object> details = new HashMap<>();
    details.put(Constants.SUMMARY_KEY, new HashMap<>());
    if (scannerType.equals(AST)) {
        createAstFindings(result);
    }
    result.setAdditionalDetails(details);
    result.setXIssues(ScanResultsBuilder.get2XIssues());
    return result;
}
Also used : ScanResults(com.checkmarx.sdk.dto.ScanResults) CxScanSummary(com.checkmarx.sdk.dto.cx.CxScanSummary)

Example 49 with ScanResults

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

the class CxConfigSteps method processScanResultsInCxFlow.

private void processScanResultsInCxFlow() throws InterruptedException {
    try {
        ScanRequest scanRequest = createScanRequest();
        CompletableFuture<ScanResults> task = resultsService.processScanResultsAsync(scanRequest, 0, 0, null, null);
        task.get(1, TimeUnit.MINUTES);
    } catch (MachinaException | ExecutionException | TimeoutException e) {
        String message = "Error processing scan results.";
        log.error(message, e);
        Assert.fail(message);
    }
}
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 50 with ScanResults

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

the class CxConfigSteps method createFakeScanResults.

private static ScanResults createFakeScanResults() {
    ScanResults result = new ScanResults();
    result.setScanSummary(new CxScanSummary());
    Map<String, Object> details = new HashMap<>();
    details.put(Constants.SUMMARY_KEY, new HashMap<>());
    result.setAdditionalDetails(details);
    result.setXIssues(new ArrayList<>());
    return result;
}
Also used : ScanResults(com.checkmarx.sdk.dto.ScanResults) CxScanSummary(com.checkmarx.sdk.dto.cx.CxScanSummary)

Aggregations

ScanResults (com.checkmarx.sdk.dto.ScanResults)58 MachinaException (com.checkmarx.flow.exception.MachinaException)17 ScanRequest (com.checkmarx.flow.dto.ScanRequest)16 CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)14 When (io.cucumber.java.en.When)9 MachinaRuntimeException (com.checkmarx.flow.exception.MachinaRuntimeException)6 CxScanSummary (com.checkmarx.sdk.dto.cx.CxScanSummary)6 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)6 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 BugTracker (com.checkmarx.flow.dto.BugTracker)4 ScanParams (com.checkmarx.sdk.dto.ast.ScanParams)4 Filter (com.checkmarx.sdk.dto.sast.Filter)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 JiraClientException (com.checkmarx.flow.exception.JiraClientException)3 CxScanParams (com.checkmarx.sdk.dto.cx.CxScanParams)3 Finding (com.checkmarx.sdk.dto.sca.report.Finding)3 Package (com.checkmarx.sdk.dto.sca.report.Package)3 IOException (java.io.IOException)3