use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class CreateScanBatchRunnerWithCustomUrl method createScanBatchRunner.
public ScanBatchRunner createScanBatchRunner(String providedUrl, ConnectionDetails connectionDetails, BlackDuckRegistrationService registrationService, File installDirectory) throws DetectUserFriendlyException {
logger.debug("Signature scanner will use the provided url to download/update the scanner.");
HttpUrl baseUrl;
try {
baseUrl = new HttpUrl(providedUrl);
} catch (IntegrationException e) {
throw new DetectUserFriendlyException("User provided scanner install url could not be parsed: " + providedUrl, e, ExitCodeType.FAILURE_CONFIGURATION);
}
CleanupZipExpander cleanupZipExpander = new CleanupZipExpander(slf4jIntLogger);
SignatureScannerClient signatureScannerClient = new SignatureScannerClient(new SilentIntLogger(), connectionDetails.getGson(), connectionDetails.getTimeout().intValue(), connectionDetails.getAlwaysTrust(), connectionDetails.getProxyInformation());
KeyStoreHelper keyStoreHelper = new KeyStoreHelper(slf4jIntLogger);
ScannerZipInstaller scannerZipInstaller = new ScannerZipInstaller(slf4jIntLogger, signatureScannerClient, registrationService, cleanupZipExpander, scanPathsUtility, keyStoreHelper, baseUrl, operatingSystemType, installDirectory);
return ScanBatchRunner.createComplete(intEnvironmentVariables, scanPathsUtility, scanCommandRunner, scannerZipInstaller);
}
use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class CreateScanBatchOperation method createScanBatch.
private ScanBatch createScanBatch(NameVersion projectNameVersion, List<SignatureScanPath> signatureScanPaths, @Nullable BlackDuckServerConfig blackDuckServerConfig, @Nullable DockerTargetData dockerTargetData) throws DetectUserFriendlyException {
ScanBatchBuilder scanJobBuilder = new ScanBatchBuilder();
scanJobBuilder.scanMemoryInMegabytes(signatureScannerOptions.getScanMemory());
scanJobBuilder.outputDirectory(directoryManager.getScanOutputDirectory());
scanJobBuilder.dryRun(signatureScannerOptions.getDryRun());
scanJobBuilder.cleanupOutput(false);
signatureScannerOptions.getSnippetMatching().ifPresent(scanJobBuilder::snippetMatching);
scanJobBuilder.uploadSource(signatureScannerOptions.getUploadSource());
scanJobBuilder.licenseSearch(signatureScannerOptions.getLicenseSearch());
scanJobBuilder.copyrightSearch(signatureScannerOptions.getCopyrightSearch());
signatureScannerOptions.getAdditionalArguments().ifPresent(scanJobBuilder::additionalScanArguments);
String projectName = projectNameVersion.getName();
String projectVersionName = projectNameVersion.getVersion();
scanJobBuilder.projectAndVersionNames(projectName, projectVersionName);
signatureScannerOptions.getIndividualFileMatching().ifPresent(scanJobBuilder::individualFileMatching);
File sourcePath = directoryManager.getSourceDirectory();
for (SignatureScanPath scanPath : signatureScanPaths) {
File dockerTarget = null;
if (dockerTargetData != null) {
dockerTarget = dockerTargetData.getSquashedImage().orElse(dockerTargetData.getProvidedImageTar().orElse(null));
}
String codeLocationName = codeLocationNameManager.createScanCodeLocationName(sourcePath, scanPath.getTargetPath(), dockerTarget, projectName, projectVersionName);
scanJobBuilder.addTarget(ScanTarget.createBasicTarget(scanPath.getTargetCanonicalPath(), scanPath.getExclusions(), codeLocationName));
}
// when offline, we must still call this with 'null' as a workaround for library issues, so offline scanner must be created with this set to null.
scanJobBuilder.fromBlackDuckServerConfig(blackDuckServerConfig);
try {
return scanJobBuilder.build();
} catch (IllegalArgumentException e) {
throw new DetectUserFriendlyException(e.getMessage(), e, ExitCodeType.FAILURE_CONFIGURATION);
}
}
use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class OperationFactory method waitForCodeLocations.
public void waitForCodeLocations(BlackDuckRunData blackDuckRunData, CodeLocationWaitData codeLocationWaitData, NameVersion projectNameVersion) throws OperationException {
auditLog.namedPublic("Wait for Code Locations", () -> {
// TODO fix this when NotificationTaskRange doesn't include task start time
// ekerwin - The start time of the task is the earliest time a code location was created.
// In order to wait the full timeout, we have to not use that start time and instead use now().
// TODO: Handle the possible null pointer here.
NotificationTaskRange notificationTaskRange = new NotificationTaskRange(System.currentTimeMillis(), codeLocationWaitData.getNotificationRange().getStartDate(), codeLocationWaitData.getNotificationRange().getEndDate());
CodeLocationCreationService codeLocationCreationService = blackDuckRunData.getBlackDuckServicesFactory().createCodeLocationCreationService();
CodeLocationWaitResult result = codeLocationCreationService.waitForCodeLocations(notificationTaskRange, projectNameVersion, codeLocationWaitData.getCodeLocationNames(), codeLocationWaitData.getExpectedNotificationCount(), detectConfigurationFactory.findTimeoutInSeconds());
if (result.getStatus() == CodeLocationWaitResult.Status.PARTIAL) {
throw new DetectUserFriendlyException(result.getErrorMessage().orElse("Timed out waiting for code locations to finish on the Black Duck server."), ExitCodeType.FAILURE_TIMEOUT);
}
});
}
use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class AirGapFontLocator method locateFontFile.
private File locateFontFile(String defaultFontFileName, String customFontDirectoryName) throws DetectUserFriendlyException {
File fontFile = airGapPaths.getFontsAirGapDirectory().map(fontAirGapDirectory -> locateFontFile(fontAirGapDirectory, defaultFontFileName, customFontDirectoryName)).orElseThrow(() -> new DetectUserFriendlyException(String.format("Could not get the font file %s from the air gap path", defaultFontFileName), ExitCodeType.FAILURE_GENERAL_ERROR));
logger.debug("Locating font file {}", fontFile.getAbsolutePath());
return fontFile;
}
use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class OnlineDetectFontLocator method locateFontFile.
private File locateFontFile(String fontFileName, String customFontDirectoryName) throws DetectUserFriendlyException {
try {
File fontsDirectory = directoryManager.getPermanentDirectory("fonts");
File customFontFile = locateCustomFontFile(fontsDirectory, customFontDirectoryName);
File fontFile;
if (customFontFile != null) {
fontFile = customFontFile;
} else {
fontFile = new File(fontsDirectory, fontFileName);
}
logger.debug("Locating font file {}", fontFile.getAbsolutePath());
if (!fontFile.exists()) {
detectFontInstaller.installFonts(fontsDirectory);
}
return fontFile;
} catch (Exception e) {
throw new DetectUserFriendlyException("Unable to locate font files or install fonts from Artifactory.", e, ExitCodeType.FAILURE_GENERAL_ERROR);
}
}
Aggregations