Search in sources :

Example 1 with CxScanEngine

use of com.checkmarx.sdk.dto.cx.CxScanEngine in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class ScanSettingsClientImpl method getEngineConfigurationId.

@Override
public int getEngineConfigurationId(String configurationName) throws CheckmarxException {
    HttpEntity<Void> httpEntity = new HttpEntity<>(authClient.createAuthHeaders());
    int defaultConfigId = Constants.UNKNOWN_INT;
    try {
        log.info("Retrieving Cx engineConfigurations");
        ResponseEntity<CxScanEngine[]> response = restTemplate.exchange(cxProperties.getUrl().concat(ENGINE_CONFIGURATIONS), HttpMethod.GET, httpEntity, CxScanEngine[].class);
        CxScanEngine[] engines = response.getBody();
        if (engines == null) {
            throw new CheckmarxException("Error obtaining Scan configurations");
        }
        log.debug("Engine configurations found: {}.", engines.length);
        for (CxScanEngine engine : engines) {
            String engineName = engine.getName();
            int engineId = engine.getId();
            if (engineName.equalsIgnoreCase(configurationName)) {
                log.info("Found xml/engine configuration {} with ID {}", configurationName, engineId);
                return engineId;
            }
        }
        log.warn("No scan configuration found for {}", configurationName);
        log.warn("Scan Configuration {} with ID {} will be used instead", Constants.CX_DEFAULT_CONFIGURATION, defaultConfigId);
        return defaultConfigId;
    } catch (HttpStatusCodeException e) {
        log.error("Error occurred while retrieving engine configurations");
        log.error(ExceptionUtils.getStackTrace(e));
        throw new CheckmarxException("Error obtaining Configuration Id");
    }
}
Also used : CxScanEngine(com.checkmarx.sdk.dto.cx.CxScanEngine) HttpEntity(org.springframework.http.HttpEntity) CheckmarxException(com.checkmarx.sdk.exception.CheckmarxException) HttpStatusCodeException(org.springframework.web.client.HttpStatusCodeException)

Aggregations

CxScanEngine (com.checkmarx.sdk.dto.cx.CxScanEngine)1 CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpStatusCodeException (org.springframework.web.client.HttpStatusCodeException)1