use of com.checkmarx.flow.exception.MachinaException in project cx-flow by checkmarx-ltd.
the class AbstractVulnerabilityScanner method getLatestScanResultsAsync.
public CompletableFuture<ScanResults> getLatestScanResultsAsync(ScanRequest request, CxProject cxProject) {
try {
CxProject project;
if (cxProject == null) {
Integer projectId = getProjectId(request);
if (projectId.equals(UNKNOWN_INT)) {
log.warn("No project found for {}", request.getProject());
return CompletableFuture.completedFuture(null);
}
project = getScannerClient().getProject(projectId);
} else {
project = cxProject;
}
Integer scanId = getScannerClient().getLastScanId(project.getId());
if (scanId.equals(UNKNOWN_INT)) {
log.warn("No Scan Results to process for project {}", project.getName());
CompletableFuture<ScanResults> x = new CompletableFuture<>();
x.complete(null);
return x;
}
setCxFields(project, request);
// null is passed for osaScanId as it is not applicable here and will be ignored
return resultsService.processScanResultsAsync(request, project.getId(), scanId, null, request.getFilter());
} catch (MachinaException | CheckmarxException e) {
log.error("Error occurred while processing results for {}{}", request.getTeam(), request.getProject(), e);
CompletableFuture<ScanResults> x = new CompletableFuture<>();
x.completeExceptionally(e);
return x;
}
}
use of com.checkmarx.flow.exception.MachinaException in project cx-flow by checkmarx-ltd.
the class AbstractVulnerabilityScanner method scanLocalPath.
private ScanResults scanLocalPath(ScanRequest request, String path) throws ExitThrowable {
ScanResults results = null;
try {
String effectiveProjectName = projectNameGenerator.determineProjectName(request);
request.setProject(effectiveProjectName);
overrideScanPreset(request);
File zipFile = ZipUtils.zipToTempFile(path, flowProperties.getZipExclude());
ScanDetails details = executeCxScan(request, zipFile);
results = getScanResults(request, details.getProjectId(), details.getScanId());
log.debug("Deleting temp file {}", zipFile.getPath());
Files.deleteIfExists(zipFile.toPath());
} catch (IOException e) {
log.error("Error occurred while attempting to zip path {}", path, e);
exit(3);
} catch (MachinaException | CheckmarxException e) {
log.error("Error occurred", e);
exit(3);
}
return results;
}
use of com.checkmarx.flow.exception.MachinaException in project cx-flow by checkmarx-ltd.
the class AbstractVulnerabilityScanner method scanRemoteRepo.
private ScanResults scanRemoteRepo(ScanRequest request) throws ExitThrowable {
ScanResults results = null;
try {
String effectiveProjectName = projectNameGenerator.determineProjectName(request);
request.setProject(effectiveProjectName);
ScanDetails details = executeCxScan(request, null);
results = getScanResults(request, details.getProjectId(), details.getScanId());
} catch (MachinaException | CheckmarxException e) {
log.error("Error occurred", e);
exit(3);
}
return results;
}
use of com.checkmarx.flow.exception.MachinaException in project cx-flow by checkmarx-ltd.
the class ImmutableIssueTracker method writeJsonOutput.
/**
* Common function for writing POJO to Json file output using mapper
*/
public void writeJsonOutput(ScanRequest request, Object report, Logger log) throws MachinaException {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.writeValue(new File(request.getFilename()).getCanonicalFile(), report);
} catch (IOException e) {
log.error("Issue occurred while writing file {}", request.getFilename(), e);
throw new MachinaException();
}
}
use of com.checkmarx.flow.exception.MachinaException 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);
}
}
Aggregations