use of com.checkmarx.sdk.dto.ScanResults in project cx-flow by checkmarx-ltd.
the class SastScanner method cxParseResults.
public void cxParseResults(ScanRequest request, File file) throws ExitThrowable {
try {
ScanResults results = cxService.getReportContent(file, request.getFilter());
resultsService.processResults(request, results, scanDetails);
if (flowProperties.isBreakBuild() && results != null && results.getXIssues() != null && !results.getXIssues().isEmpty()) {
log.error(ERROR_BREAK_MSG);
exit(ExitCode.BUILD_INTERRUPTED);
}
} catch (MachinaException | CheckmarxException e) {
log.error("Error occurred while processing results file", e);
exit(3);
}
}
use of com.checkmarx.sdk.dto.ScanResults in project cx-flow by checkmarx-ltd.
the class OsaScannerService method cxOsaParseResults.
public void cxOsaParseResults(ScanRequest request, File file, File libs) throws ExitThrowable {
try {
List<Filter> simpleFilters = Optional.ofNullable(request).map(ScanRequest::getFilter).map(FilterConfiguration::getSastFilters).map(EngineFilterConfiguration::getSimpleFilters).orElse(null);
ScanResults results = cxService.getOsaReportContent(file, libs, simpleFilters);
resultsService.processResults(request, results, scanDetails);
if (flowProperties.isBreakBuild() && results != null && results.getXIssues() != null && !results.getXIssues().isEmpty()) {
log.error(ERROR_BREAK_MSG);
exit(ExitCode.BUILD_INTERRUPTED);
}
} catch (MachinaException | CheckmarxException e) {
log.error("Error occurred while processing results file(s)", e);
exit(3);
}
}
use of com.checkmarx.sdk.dto.ScanResults in project cx-flow by checkmarx-ltd.
the class ResultsService method publishCombinedResults.
@Async("scanRequest")
public CompletableFuture<ScanResults> publishCombinedResults(ScanRequest scanRequest, ScanResults scanResults) {
try {
CompletableFuture<ScanResults> future = new CompletableFuture<>();
if (scanResults.getProjectId() != null) {
Integer projectId = Integer.parseInt(scanResults.getProjectId());
if (projectId != UNKNOWN_INT) {
logGetResultsJsonLogger(scanRequest, scanResults.getSastScanId(), scanResults);
sendEmailNotification(scanRequest, scanResults);
processResults(scanRequest, scanResults, new ScanDetails(projectId, scanResults.getSastScanId(), null));
logScanDetails(scanRequest, projectId, scanResults);
} else {
processResults(scanRequest, scanResults, new ScanDetails(null, scanResults.getSastScanId(), null));
}
} else {
processResults(scanRequest, scanResults, new ScanDetails(null, scanResults.getSastScanId(), null));
}
future.complete(scanResults);
log.info("Finished processing the request");
return future;
} catch (Exception e) {
log.error("Error occurred while processing results.", e);
CompletableFuture<ScanResults> x = new CompletableFuture<>();
x.completeExceptionally(e);
return x;
}
}
use of com.checkmarx.sdk.dto.ScanResults in project cx-flow by checkmarx-ltd.
the class GitHubCommentsASTSteps method getASTResults.
@And("doing get results operation on scan with {int} {int} {int} {int} results")
public void getASTResults(int high, int medium, int low, int info) throws InterruptedException {
try {
if (scannerType.equalsIgnoreCase(AST)) {
scanResultsToInject = createFakeASTScanResults(high, medium, low);
addFlowSummaryToResults(high, medium, low, info);
}
if (scannerType.equalsIgnoreCase(AST_SCA)) {
scanResultsToInject = createFakeSCAScanResults(high, medium, low);
ScanResults astScanResults = createFakeASTScanResults(high, medium, low);
scanResultsToInject.setAstResults(astScanResults.getAstResults());
addFlowSummaryToResults(high * 2, medium * 2, low * 2, info * 2);
}
ScanRequest scanRequest = createScanRequest();
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);
}
}
use of com.checkmarx.sdk.dto.ScanResults in project cx-flow by checkmarx-ltd.
the class CommentScriptSteps method setMockers.
@Before("@ConfigureSastComment")
public void setMockers() throws CheckmarxException {
when(cxClientMock.getScanIdOfExistingScanIfExists(anyInt())).thenReturn(-1);
when(cxClientMock.createScan(any(), anyString())).thenAnswer(invocation -> {
commentMessageFromRequest = invocation.getArgument(1);
return null;
});
when(cxClientMock.getReportContentByScanId(nullable(Integer.class), any())).thenReturn(new ScanResults());
when(sastScanner.getScannerClient()).thenReturn(cxClientMock);
when(sastScanner.getScanRequestConverter()).thenReturn(scanRequestConverterMock);
when(sastScanner.getScanComment(any())).thenCallRealMethod();
when(sastScanner.getCxPropertiesBase()).thenReturn(cxProperties);
when(sastScanner.isEnabled()).thenReturn(true);
when(sastScanner.scan(any())).thenCallRealMethod();
CxScanParams cxScanParams = new CxScanParams();
cxScanParams.setProjectId(1);
when(scanRequestConverterMock.toScanParams(any())).thenReturn(cxScanParams);
cxProperties.setProjectScript(EMPTY_STRING);
flowProperties.setBugTracker(BugTracker.Type.NONE.toString());
commentMessageFromRequest = EMPTY_STRING;
branchName = EMPTY_STRING;
}
Aggregations