use of com.checkmarx.sdk.dto.cx.CxScanParams in project cx-flow by checkmarx-ltd.
the class AbstractVulnerabilityScanner method executeCxScan.
public ScanDetails executeCxScan(ScanRequest request, File cxFile) throws MachinaException {
String osaScanId;
Integer scanId = null;
Integer projectId;
try {
/*Check if team is provided*/
String ownerId = getScanRequestConverter().determineTeamAndOwnerID(request);
log.debug("Auto profiling is enabled");
projectId = getScanRequestConverter().determinePresetAndProjectId(request, ownerId);
CxScanParams params = getScanRequestConverter().prepareScanParamsObject(request, cxFile, ownerId, projectId);
scanId = getScannerClient().createScan(params, getComment(request));
osaScanId = createOsaScan(request, projectId);
if (osaScanId != null) {
logRequest(request, osaScanId, cxFile, OperationResult.successful());
}
} catch (GitHubRepoUnavailableException e) {
// an error stack trace in the log.
return new ScanDetails(UNKNOWN_INT, UNKNOWN_INT, new CompletableFuture<>(), false);
} catch (CheckmarxException | GitAPIException e) {
String extendedMessage = treatFailure(request, cxFile, scanId, e);
throw new MachinaException("Checkmarx Error Occurred: " + extendedMessage);
}
logRequest(request, scanId, cxFile, OperationResult.successful());
this.scanDetails = new ScanDetails(projectId, scanId, osaScanId);
return scanDetails;
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class GoScanner method getProjectId.
public Integer getProjectId(String ownerId, String name) {
log.debug("Retrieving OD Project List");
OdProjectList appList = getProjectPage(ownerId);
for (OdProjectListDataItem item : appList.getData().getItems()) {
if (item.getName().equals(name)) {
CxScanParams csp = getScanProbeByTeam(ownerId);
csp.setProjectId(item.getId());
return item.getId();
}
}
return UNKNOWN_INT;
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxGoServiceIT method gitClone.
@Test
// works only on Windows
@Ignore
public void gitClone() throws CheckmarxException {
login();
CxScanParams params = new CxScanParams();
params.setProjectName("CircleCI");
params.setTeamId("1");
params.setGitUrl("https://github.com/Custodela/Riches.git");
params.setBranch("refs/heads/master");
params.setSourceType(CxScanParams.Type.GIT);
String zipFilePath = repoFileService.prepareRepoFile(params);
assertTrue("Zip file path is empty.", StringUtils.isNotEmpty(zipFilePath));
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxGoServiceIT method completeScanFlow.
@Test
// works only on Windows
@Ignore
public void completeScanFlow() throws CheckmarxException {
login();
if (StringUtils.isNotEmpty(properties.getClientSecret())) {
String teamId = service.getTeamId(properties.getTeam());
Integer projectId = service.getProjectId(teamId, GO_PROJECT_NAME);
CxScanParams params = new CxScanParams();
params.setProjectName(GO_PROJECT_NAME);
params.setTeamId(teamId);
params.setProjectId(projectId);
params.setGitUrl("https://github.com/Custodela/Riches.git");
params.setBranch("refs/heads/master");
params.setSourceType(CxScanParams.Type.GIT);
// run the scan and wait for it to finish
Integer x = service.createScan(params, "CxFlow Scan");
service.waitForScanCompletion(x);
FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(Collections.singletonList(new Filter(Filter.Type.SEVERITY, "High")));
// generate the results
ScanResults results = service.getReportContentByScanId(x, filterConfiguration);
assertNotNull(results);
}
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxServiceIT method completeScanFlow.
@Test
@Ignore("Stable environment required")
public void completeScanFlow() throws CheckmarxException {
final String PROJECT_NAME = "my-project-name";
final String GIT_REPO_URL = "https://github.com/my-organization/my-repo.git";
final String BRANCH_NAME = "refs/heads/develop";
String teamId = service.getTeamId(properties.getTeam());
Integer projectId = service.getProjectId(teamId, PROJECT_NAME);
CxScanParams params = new CxScanParams();
params.setProjectName(PROJECT_NAME);
params.setTeamId(teamId);
params.setProjectId(projectId);
params.setGitUrl(GIT_REPO_URL);
params.setBranch(BRANCH_NAME);
params.setSourceType(CxScanParams.Type.GIT);
// run the scan and wait for it to finish
Integer x = service.createScan(params, "CxSDK Scan");
service.waitForScanCompletion(x);
List<Filter> highSeverityOnly = Collections.singletonList(new Filter(Filter.Type.SEVERITY, "High"));
FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(highSeverityOnly);
// generate the results
ScanResults results = service.getReportContentByScanId(x, filterConfiguration);
assertNotNull(results);
}
Aggregations