Search in sources :

Example 1 with BinaryScanOptions

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();
    }
}
Also used : Optional(java.util.Optional) BinaryScanOptions(com.synopsys.integration.detect.tool.binaryscanner.BinaryScanOptions) File(java.io.File)

Example 2 with BinaryScanOptions

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());
}
Also used : Path(java.nio.file.Path) DetectDirectoryFileFilter(com.synopsys.integration.detect.util.finder.DetectDirectoryFileFilter) StringUtils(org.apache.commons.lang3.StringUtils) BinaryScanOptions(com.synopsys.integration.detect.tool.binaryscanner.BinaryScanOptions)

Aggregations

BinaryScanOptions (com.synopsys.integration.detect.tool.binaryscanner.BinaryScanOptions)2 DetectDirectoryFileFilter (com.synopsys.integration.detect.util.finder.DetectDirectoryFileFilter)1 File (java.io.File)1 Path (java.nio.file.Path)1 Optional (java.util.Optional)1 StringUtils (org.apache.commons.lang3.StringUtils)1