use of com.checkmarx.flow.config.external.CxGoConfigFromWebService in project cx-flow by checkmarx-ltd.
the class ConfigurationOverrider method applyCxGoDynamicConfig.
private void applyCxGoDynamicConfig(Map<String, String> overrideReport, ScanRequest request) {
if (cxIntegrationsProperties.isReadMultiTenantConfiguration()) {
String orgId = Optional.ofNullable(request.getOrganizationId()).orElseThrow(() -> new MachinaRuntimeException("Organization id is missing for SCM: " + request.getRepoType().getRepository()));
CxGoConfigFromWebService cxgoConfig = reposManagerService.getCxGoDynamicConfig(request.getGitUrl(), orgId);
if (cxgoConfig == null) {
log.error("Multi Tenant mode: missing CxGo configuration in Repos Manager Service. Working with Multi Tenant = false ");
return;
}
String className = CxGoConfigFromWebService.class.getSimpleName();
log.info("Applying {} configuration.", className);
Optional.ofNullable(cxgoConfig.getTeam()).filter(StringUtils::isNotEmpty).ifPresent(team -> {
request.setTeam(team);
log.info("Using team from {}", className);
overrideReport.put(TEAM_REPORT_KEY, team);
});
Optional.ofNullable(cxgoConfig.getCxgoToken()).filter(StringUtils::isNotEmpty).ifPresent(secret -> {
request.setScannerApiSec(secret);
log.info("Using scanner API secret from {}", className);
overrideReport.put("scannerApiSec", "<actually it's a secret>");
});
Optional.ofNullable(cxgoConfig.getScmAccessToken()).filter(StringUtils::isNotEmpty).ifPresent(token -> {
String authUrl = gitAuthUrlGenerator.addCredToUrl(request.getRepoType(), request.getGitUrl(), cxgoConfig.getScmAccessToken());
request.setRepoUrlWithAuth(authUrl);
log.info("Using SCM token from {}", className);
overrideReport.put("SCM token", "********");
});
}
}
Aggregations