Search in sources :

Example 16 with RestClientConfig

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

the class ScaTest method scanRemoteRepo.

private void scanRemoteRepo(String repoUrlProp, boolean useOnPremAuthentication) throws MalformedURLException {
    RestClientConfig config = initScaConfig(repoUrlProp, useOnPremAuthentication);
    AstScaResults scanResults = runScan(config);
    verifyScanResults(scanResults);
}
Also used : AstScaResults(com.checkmarx.sdk.dto.AstScaResults) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig)

Example 17 with RestClientConfig

use of com.checkmarx.sdk.config.RestClientConfig 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 18 with RestClientConfig

use of com.checkmarx.sdk.config.RestClientConfig 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);
    }
}
Also used : IScanClientHelper(com.checkmarx.sdk.utils.scanner.client.IScanClientHelper) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException)

Example 19 with RestClientConfig

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

the class ScaScanner method getScanConfig.

/**
 * Convert scanParams to an object that is used by underlying logic in Common Client.
 */
@Override
public RestClientConfig getScanConfig(ScanParams scanParams) {
    RestClientConfig restClientConfig = new RestClientConfig();
    restClientConfig.setProjectName(scanParams.getProjectName());
    restClientConfig.setDisableCertificateValidation(scanParams.isDisableCertificateValidation());
    ScaConfig scaConfig = getScaSpecificConfig(scanParams);
    setSourceLocation(scanParams, restClientConfig, scaConfig);
    if (scanParams.getRemoteRepoUrl() != null) {
        restClientConfig.setClonedRepo(true);
    }
    restClientConfig.setScaConfig(scaConfig);
    return restClientConfig;
}
Also used : ScaConfig(com.checkmarx.sdk.dto.sca.ScaConfig) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig)

Aggregations

RestClientConfig (com.checkmarx.sdk.config.RestClientConfig)19 AstScaResults (com.checkmarx.sdk.dto.AstScaResults)5 Test (org.junit.Test)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 RemoteRepositoryInfo (com.checkmarx.sdk.dto.RemoteRepositoryInfo)3 ScaConfig (com.checkmarx.sdk.dto.sca.ScaConfig)3 AstConfig (com.checkmarx.sdk.config.AstConfig)2 ScannerRuntimeException (com.checkmarx.sdk.exception.ScannerRuntimeException)2 ClientTypeResolver (com.checkmarx.sdk.utils.scanner.client.ClientTypeResolver)2 IScanClientHelper (com.checkmarx.sdk.utils.scanner.client.IScanClientHelper)2 URL (java.net.URL)2 MachinaException (com.checkmarx.flow.exception.MachinaException)1 ScanResults (com.checkmarx.sdk.dto.ScanResults)1 ScanParams (com.checkmarx.sdk.dto.ast.ScanParams)1 ClientType (com.checkmarx.sdk.dto.sca.ClientType)1 CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)1 CommonClientTest (com.checkmarx.sdk.service.CommonClientTest)1 AstScanner (com.checkmarx.sdk.service.scanner.AstScanner)1 ScaClientHelper (com.checkmarx.sdk.utils.scanner.client.ScaClientHelper)1 Path (java.nio.file.Path)1