use of com.checkmarx.sdk.dto.cx.CxScanParams 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;
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class GoScanner method extractTeamId.
private String extractTeamId(String teamPath, String clientSecret) throws CheckmarxException {
String[] buTokens = teamPath.split(Pattern.quote("\\"));
OdNavigationTree navTree = getNavigationTree(clientSecret);
LinkedHashMap<String, ArrayList<Object>> navTreeData = (LinkedHashMap) navTree.getAdditionalProperties().get("data");
ArrayList<LinkedHashMap<String, LinkedHashMap<String, Object>>> tree = (ArrayList) navTreeData.get("tree");
int i = 1;
String token = buTokens[i++];
for (LinkedHashMap<String, LinkedHashMap<String, Object>> item : tree) {
Object o = item.get("id");
Integer id = (Integer) o;
o = item.get("title");
String title = (String) o;
title = title.trim();
o = item.get("children");
ArrayList<Object> children = (ArrayList<Object>) o;
if (title.equals(token)) {
if (i == buTokens.length) {
CxScanParams csp = getScanProbeByTeam(id.toString());
csp.setTeamName(teamPath);
return id.toString();
} else {
return searchTreeChildren(teamPath, buTokens, i, children);
}
}
}
return UNKNOWN;
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxServiceIT method createScan.
@Test
public void createScan() {
log.info("Creating scan");
login();
try {
CxScanParams params = new CxScanParams().withSourceType(CxScanParams.Type.GIT).withGitUrl("https://github.com/Custodela/Riches.git").withBranch("refs/heads/master").withProjectName("CxSBSDK-IT");
// .withProjectName("Riches");
// String teamId = service.getTeamId(properties.getTeam());
Integer id = service.createScan(params, "Automated Comment");
assertNotNull(id);
assertTrue(id > 0);
} catch (CheckmarxException e) {
fail("Unexpected CheckmarxException");
}
}
use of com.checkmarx.sdk.dto.cx.CxScanParams in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxRepoFileHelper method getScaClonedRepoFolderPath.
public String getScaClonedRepoFolderPath(String repoUrlWithAuth, List<String> excludeFiles, String branch) throws CheckmarxException {
CxScanParams cxScanParams = prepareScanParamsToCloneRepo(repoUrlWithAuth, excludeFiles, branch);
File pathFile = null;
try {
pathFile = gitCloneAndRunPostCloneScript(cxScanParams);
} catch (GitAPIException | URISyntaxException e) {
log.error(ExceptionUtils.getRootCauseMessage(e));
throw new CheckmarxException("Unable to clone Git Url.");
}
return pathFile.getAbsolutePath();
}
Aggregations