use of com.checkmarx.flow.exception.MachinaRuntimeException 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", "********");
});
}
}
use of com.checkmarx.flow.exception.MachinaRuntimeException in project cx-flow by checkmarx-ltd.
the class SCAScanner method setScannerSpecificProperties.
@Override
protected void setScannerSpecificProperties(ScanRequest scanRequest, ScanParams scanParams) {
try {
// report in xml format
if (!ScanUtils.empty(scanRequest.getBugTracker().getCustomBean()) && scanRequest.getBugTracker().getCustomBean().equalsIgnoreCase("CxXml")) {
scaProperties.setPreserveXml(true);
}
if (scaProperties.isEnabledZipScan()) {
log.info("CxAST-SCA zip scan is enabled");
String scaClonedFolderPath = cxRepoFileHelper.getScaClonedRepoFolderPath(scanRequest.getRepoUrlWithAuth(), scanRequest.getExcludeFiles(), scanRequest.getBranch());
scanParams.setSourceDir(scaClonedFolderPath);
}
if (scanRequest.getExcludeFiles() != null) {
scanParams.getScaConfig().setExcludeFiles(scanRequest.getExcludeFiles());
} else if (scaProperties.getExcludeFiles() != null) {
List<String> excludeFiles = new ArrayList<String>(Arrays.asList(scaProperties.getExcludeFiles().split(",")));
log.debug("Exclude Files list contains : {}", excludeFiles);
scanParams.getScaConfig().setExcludeFiles(excludeFiles);
}
} catch (CheckmarxException e) {
log.error("Error occurred while setting scanner properties", e);
throw new MachinaRuntimeException(e.getMessage());
}
}
use of com.checkmarx.flow.exception.MachinaRuntimeException in project cx-flow by checkmarx-ltd.
the class ScanUtils method getMachinaOverride.
public static FlowOverride getMachinaOverride(@RequestParam(value = "override", required = false) String override) {
FlowOverride o = null;
try {
ObjectMapper mapper = new ObjectMapper();
// if override is provided, check if chars are more than 20 in length, implying base64 encoded json
if (!ScanUtils.empty(override)) {
if (override.length() > 20) {
String oJson = new String(Base64.getDecoder().decode(override));
o = mapper.readValue(oJson, FlowOverride.class);
log.info("Overriding attributes with Base64 encoded String");
} else {
// TODO download file
}
}
} catch (IOException e) {
log.error("Error occurred", e);
throw new MachinaRuntimeException();
}
return o;
}
Aggregations