use of com.checkmarx.sdk.exception.ScannerRuntimeException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxHttpClient method revokeToken.
public void revokeToken(String token) throws IOException {
UrlEncodedFormEntity requestEntity = getRevocationRequest(ClientType.CLI, token);
HttpPost post = new HttpPost(rootUri + REVOCATION);
try {
request(post, ContentType.APPLICATION_FORM_URLENCODED.toString(), requestEntity, String.class, HttpStatus.SC_OK, "revocation", false, false);
} catch (ScannerRuntimeException e) {
throw new ScannerRuntimeException(String.format("Token revocation failure error was: %s", e.getMessage()), e);
}
}
use of com.checkmarx.sdk.exception.ScannerRuntimeException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxHttpClient method getAccessTokenFromRefreshToken.
private TokenLoginResponse getAccessTokenFromRefreshToken(LoginSettings settings) throws IOException {
UrlEncodedFormEntity requestEntity = getTokenRefreshingRequest(settings);
HttpPost post = new HttpPost(settings.getAccessControlBaseUrl());
try {
return request(post, ContentType.APPLICATION_FORM_URLENCODED.toString(), requestEntity, TokenLoginResponse.class, HttpStatus.SC_OK, AUTH_MESSAGE, false, false);
} catch (ScannerRuntimeException e) {
throw new ScannerRuntimeException(String.format("Failed to generate access token from refresh token. The error was: %s", e.getMessage()), e);
}
}
use of com.checkmarx.sdk.exception.ScannerRuntimeException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class ScaScanner method getLatestScanResults.
public AstScaResults getLatestScanResults(ScanParams scanParams) {
RestClientConfig config = getScanConfig(scanParams);
try {
IScanClientHelper client = allocateClient(config);
client.init();
ResultsBase results = client.getLatestScanResults();
AstScaResults result;
if (results != null) {
result = toResults(results);
applyFilterToResults(result, scanParams);
} else {
result = new AstScaResults();
}
return result;
} catch (Exception e) {
throw new ScannerRuntimeException("Error getting latest scan results.", e);
}
}
use of com.checkmarx.sdk.exception.ScannerRuntimeException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class AstClientHelper method retrieveScanResults.
private ASTResults retrieveScanResults() {
try {
ASTResults result = new ASTResults();
result.setScanId(scanId);
AstSummaryResults scanSummary = getSummary();
result.setSummary(scanSummary);
List<Finding> findings = getFindings();
result.setFindings(findings);
String projectLink = getWebReportLink(config.getAstConfig().getWebAppUrl());
result.setWebReportLink(projectLink);
return result;
} catch (IOException e) {
String message = String.format("Error getting %s scan results.", getScannerDisplayName());
throw new ScannerRuntimeException(message, e);
}
}
use of com.checkmarx.sdk.exception.ScannerRuntimeException in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class AstClientHelper method initiateScan.
@Override
public ResultsBase initiateScan() {
log.info("----------------------------------- Initiating {} Scan:------------------------------------", getScannerDisplayName());
ASTResults astResults = new ASTResults();
scanId = null;
AstConfig astConfig = config.getAstConfig();
try {
SourceLocationType locationType = astConfig.getSourceLocationType();
HttpResponse response;
String projectId = determineProjectId(config.getProjectName());
if (locationType == SourceLocationType.REMOTE_REPOSITORY) {
response = submitSourcesFromRemoteRepo(projectId, astConfig);
} else {
response = submitAllSourcesFromLocalDir(projectId, astConfig);
}
scanId = extractScanIdFrom(response);
astResults.setScanId(scanId);
} catch (Exception e) {
log.error(e.getMessage());
setState(State.FAILED);
astResults.setException(new ScannerRuntimeException("Error creating scan.", e));
}
return astResults;
}
Aggregations