Search in sources :

Example 1 with RestClientConfig

use of com.checkmarx.sdk.config.RestClientConfig in project cx-flow by checkmarx-ltd.

the class SCAScanner method cxParseResults.

@Override
protected void cxParseResults(ScanRequest scanRequest, File file) throws ExitThrowable {
    RestClientConfig restClientConfig;
    IScanClientHelper iScanClientHelper;
    try {
        ScanParams sdkScanParams = ScanParams.builder().projectName(scanRequest.getProject()).scaConfig(scanRequest.getScaConfig()).filterConfiguration(scanRequest.getFilter()).build();
        restClientConfig = scaScannerClient.getScanConfig(sdkScanParams);
        iScanClientHelper = new ScaClientHelper(restClientConfig, log, scaProperties);
        ScanResults results = iScanClientHelper.getReportContent(file, scanRequest.getFilter());
        resultsService.processResults(scanRequest, results, scanDetails);
        if (flowProperties.isBreakBuild() && results != null && results.getXIssues() != null && !results.getXIssues().isEmpty()) {
            log.error(ERROR_BREAK_MSG);
            exit(ExitCode.BUILD_INTERRUPTED);
        }
    } catch (MachinaException | CheckmarxException e) {
        log.error("Error occurred while processing results file", e);
        exit(3);
    }
}
Also used : ScaClientHelper(com.checkmarx.sdk.utils.scanner.client.ScaClientHelper) ScanParams(com.checkmarx.sdk.dto.ast.ScanParams) ScanResults(com.checkmarx.sdk.dto.ScanResults) MachinaException(com.checkmarx.flow.exception.MachinaException) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) IScanClientHelper(com.checkmarx.sdk.utils.scanner.client.IScanClientHelper) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig)

Example 2 with RestClientConfig

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

the class ClientTypeResolverTest method checkThatExceptionIsThrown.

private static void checkThatExceptionIsThrown(String url) {
    ClientTypeResolver resolver = new ClientTypeResolver(new RestClientConfig());
    try {
        resolver.determineClientType(url);
        Assert.fail("Expected exception, but didn't get any.");
    } catch (Exception e) {
        Assert.assertTrue("Unexpected exception type.", e instanceof ScannerRuntimeException);
        Assert.assertTrue("Exception message is empty.", StringUtils.isNotEmpty(e.getMessage()));
        log.info("Got an expected exception");
    }
}
Also used : ClientTypeResolver(com.checkmarx.sdk.utils.scanner.client.ClientTypeResolver) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException) ScannerRuntimeException(com.checkmarx.sdk.exception.ScannerRuntimeException)

Example 3 with RestClientConfig

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

the class ScaTest method initScaConfig.

protected RestClientConfig initScaConfig(String repoUrlProp, boolean useOnPremAuthentication) throws MalformedURLException {
    RestClientConfig config = initScaConfig(useOnPremAuthentication);
    config.getScaConfig().setSourceLocationType(SourceLocationType.REMOTE_REPOSITORY);
    RemoteRepositoryInfo repoInfo = new RemoteRepositoryInfo();
    URL repoUrl = new URL(repoUrlProp);
    repoInfo.setUrl(repoUrl);
    repoInfo.setUsername(githubProperties.getToken());
    config.getScaConfig().setRemoteRepositoryInfo(repoInfo);
    return config;
}
Also used : RemoteRepositoryInfo(com.checkmarx.sdk.dto.RemoteRepositoryInfo) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) URL(java.net.URL)

Example 4 with RestClientConfig

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

the class ScaTest method testMissingResultsCase.

/**
 * Make sure that SCA results are null in different expected cases.
 */
private void testMissingResultsCase(String projectName) {
    log.info("Checking that scaResults are null for the {} project", projectName);
    RestClientConfig config = initScaConfig(false);
    config.setProjectName(projectName);
    AstScaResults latestResults = getLatestResults(config);
    Assert.assertNotNull("scanResults must not be null.", latestResults);
    Assert.assertNull("scaResults must be null.", latestResults.getScaResults());
}
Also used : AstScaResults(com.checkmarx.sdk.dto.AstScaResults) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig)

Example 5 with RestClientConfig

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

the class ScaTest method getLatestScanResults_existingResults.

@Test
public void getLatestScanResults_existingResults() {
    RestClientConfig config = initScaConfig(false);
    AstScaResults latestResults = getLatestResults(config);
    verifyScanResults(latestResults);
}
Also used : AstScaResults(com.checkmarx.sdk.dto.AstScaResults) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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