Search in sources :

Example 1 with AstConfig

use of com.checkmarx.sdk.config.AstConfig in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class AstScanner method getScanConfig.

/**
 * Convert scanParams to an object that is used by underlying logic in Common Client.
 */
@Override
protected RestClientConfig getScanConfig(ScanParams scanParams) {
    RestClientConfig restClientConfig = new RestClientConfig();
    restClientConfig.setProjectName(scanParams.getProjectName());
    AstConfig astConfig = getAstSpecificConfig();
    setSourceLocation(scanParams, restClientConfig, astConfig);
    restClientConfig.setAstConfig(astConfig);
    return restClientConfig;
}
Also used : RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) AstConfig(com.checkmarx.sdk.config.AstConfig)

Example 2 with AstConfig

use of com.checkmarx.sdk.config.AstConfig in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class AstTest method getScanConfig.

private RestClientConfig getScanConfig() throws MalformedURLException {
    AstConfig astConfig = AstConfig.builder().apiUrl(astProperties.getApiUrl()).webAppUrl(astProperties.getWebAppUrl()).clientSecret(astProperties.getClientSecret()).clientId("CxFlow").sourceLocationType(SourceLocationType.REMOTE_REPOSITORY).build();
    RemoteRepositoryInfo repoInfo = new RemoteRepositoryInfo();
    URL repoUrl = new URL(githubProperties.getUrl());
    repoInfo.setUrl(repoUrl);
    astConfig.setRemoteRepositoryInfo(repoInfo);
    astConfig.setResultsPageSize(10);
    astConfig.setPresetName("Checkmarx Default");
    RestClientConfig config = new RestClientConfig();
    config.setAstConfig(astConfig);
    config.setProjectName("sdkAstProject");
    config.setProgressInterval(5);
    return config;
}
Also used : RemoteRepositoryInfo(com.checkmarx.sdk.dto.RemoteRepositoryInfo) AstConfig(com.checkmarx.sdk.config.AstConfig) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) URL(java.net.URL)

Example 3 with AstConfig

use of com.checkmarx.sdk.config.AstConfig 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;
}
Also used : AstConfig(com.checkmarx.sdk.config.AstConfig) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) URISyntaxException(java.net.URISyntaxException) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) CxHTTPClientException(com.checkmarx.sdk.exception.CxHTTPClientException) RestClientException(org.springframework.web.client.RestClientException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

AstConfig (com.checkmarx.sdk.config.AstConfig)3 RestClientConfig (com.checkmarx.sdk.config.RestClientConfig)2 RemoteRepositoryInfo (com.checkmarx.sdk.dto.RemoteRepositoryInfo)1 CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)1 CxHTTPClientException (com.checkmarx.sdk.exception.CxHTTPClientException)1 ScannerRuntimeException (com.checkmarx.sdk.exception.ScannerRuntimeException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 RestClientException (org.springframework.web.client.RestClientException)1