use of com.synopsys.integration.detect.tool.binaryscanner.BinaryScanOptions in project synopsys-detect by blackducksoftware.
the class BinaryScanStepRunner method determineBinaryScanFileTarget.
public Optional<File> determineBinaryScanFileTarget(DockerTargetData dockerTargetData) throws OperationException {
BinaryScanOptions binaryScanOptions = operationFactory.calculateBinaryScanOptions();
File binaryUpload = null;
if (binaryScanOptions.getSingleTargetFilePath().isPresent()) {
logger.info("Binary upload will upload single file.");
binaryUpload = binaryScanOptions.getSingleTargetFilePath().get().toFile();
} else if (binaryScanOptions.getFileFilter().isPresent()) {
Optional<File> multipleUploadTarget = operationFactory.searchForBinaryTargets(binaryScanOptions.getFileFilter().get(), binaryScanOptions.getSearchDepth(), binaryScanOptions.isFollowSymLinks());
if (multipleUploadTarget.isPresent()) {
binaryUpload = multipleUploadTarget.get();
} else {
operationFactory.publishBinaryFailure("Binary scanner did not find any files matching any pattern.");
}
} else if (dockerTargetData != null && dockerTargetData.getContainerFilesystem().isPresent()) {
logger.info("Binary Scanner will upload docker container file system.");
binaryUpload = dockerTargetData.getContainerFilesystem().get();
}
if (binaryUpload == null) {
logger.info("Binary scanner found nothing to upload.");
return Optional.empty();
} else if (binaryUpload.isFile() && binaryUpload.canRead()) {
return Optional.of(binaryUpload);
} else {
operationFactory.publishBinaryFailure("Binary scan file did not exist, is not a file or can't be read.");
return Optional.empty();
}
}
use of com.synopsys.integration.detect.tool.binaryscanner.BinaryScanOptions in project synopsys-detect by blackducksoftware.
the class DetectConfigurationFactory method createBinaryScanOptions.
public BinaryScanOptions createBinaryScanOptions() {
Path singleTarget = detectConfiguration.getPathOrNull(DetectProperties.DETECT_BINARY_SCAN_FILE);
List<String> fileInclusionPatterns = detectConfiguration.getValue(DetectProperties.DETECT_BINARY_SCAN_FILE_NAME_PATTERNS);
DetectDirectoryFileFilter fileFilter = null;
if (fileInclusionPatterns.stream().anyMatch(StringUtils::isNotBlank)) {
fileFilter = new DetectDirectoryFileFilter(collectDirectoryExclusions(), fileInclusionPatterns);
}
Integer searchDepth = detectConfiguration.getValue(DetectProperties.DETECT_BINARY_SCAN_SEARCH_DEPTH);
return new BinaryScanOptions(singleTarget, fileFilter, searchDepth, getFollowSymLinks());
}
Aggregations