use of com.synopsys.integration.detect.util.finder.DetectExcludedDirectoryFilter in project synopsys-detect by blackducksoftware.
the class ExclusionPatternCreatorTest method testDoesNotCreateRedundantExclusions.
@Test
public void testDoesNotCreateRedundantExclusions() throws IOException {
File root = new File("root");
root.mkdir();
File foo = new File("root", "foo");
foo.mkdir();
File bar = new File(foo, "bar");
bar.mkdir();
List<String> toExclude = Arrays.asList("foo", "bar");
DetectExcludedDirectoryFilter filter = new DetectExcludedDirectoryFilter(toExclude);
ExclusionPatternCreator exclusionPatternCreator = new ExclusionPatternCreator(new SimpleFileFinder(), file -> filter.isExcluded(file), root);
Set<String> exlusionPatterns = exclusionPatternCreator.determineExclusionPatterns(false, 2, toExclude);
Assertions.assertEquals(1, exlusionPatterns.size());
Assertions.assertTrue(exlusionPatterns.contains("/foo/"));
Assertions.assertFalse(exlusionPatterns.contains("/foo/bar/"));
FileUtils.deleteDirectory(root);
}
use of com.synopsys.integration.detect.util.finder.DetectExcludedDirectoryFilter in project synopsys-detect by blackducksoftware.
the class OperationFactory method createScanPaths.
public List<SignatureScanPath> createScanPaths(NameVersion projectNameVersion, DockerTargetData dockerTargetData) throws OperationException {
return auditLog.namedInternal("Calculate Signature Scan Paths", () -> {
List<String> exclusions = detectConfigurationFactory.collectSignatureScannerDirectoryExclusions();
DetectExcludedDirectoryFilter detectExcludedDirectoryFilter = new DetectExcludedDirectoryFilter(exclusions);
return new CalculateScanPathsOperation(detectConfigurationFactory.createBlackDuckSignatureScannerOptions(), directoryManager, fileFinder, detectExcludedDirectoryFilter::isExcluded).determinePathsAndExclusions(projectNameVersion, detectConfigurationFactory.createBlackDuckSignatureScannerOptions().getMaxDepth(), dockerTargetData);
});
}
use of com.synopsys.integration.detect.util.finder.DetectExcludedDirectoryFilter in project synopsys-detect by blackducksoftware.
the class DetectExcludedDirectoryFilterTest method testIsExcludedDirectoryNamePatterns.
@Test
void testIsExcludedDirectoryNamePatterns() {
Path sourcePath = new File("my/subDir1/subDir2/file/path").toPath();
List<String> excludedDirectories = Arrays.asList("*1", "namePatternsDir*");
DetectExcludedDirectoryFilter detectExcludedDirectoryFilter = new DetectExcludedDirectoryFilter(excludedDirectories);
File root = new File(sourcePath.toFile(), "root");
File subDir1 = new File(root, "subDir1");
File subDir2 = new File(root, "subDir2");
File deepSubDir2 = new File(subDir1, "subDir2");
File namePatternsDir = new File(root, "namePatternsDir51134");
assertFalse(detectExcludedDirectoryFilter.isExcluded(root));
assertTrue(detectExcludedDirectoryFilter.isExcluded(subDir1));
assertFalse(detectExcludedDirectoryFilter.isExcluded(subDir2));
assertFalse(detectExcludedDirectoryFilter.isExcluded(deepSubDir2));
assertTrue(detectExcludedDirectoryFilter.isExcluded(namePatternsDir));
}
use of com.synopsys.integration.detect.util.finder.DetectExcludedDirectoryFilter in project synopsys-detect by blackducksoftware.
the class DetectExcludedDirectoryFilterTest method testIsExcludedDirectoryPaths.
@Test
void testIsExcludedDirectoryPaths() {
Path sourcePath = new File("my/subDir1/subDir2/file/path").toPath();
List<String> excludedDirectories = Collections.singletonList("subDir1/subDir2");
DetectExcludedDirectoryFilter detectExcludedDirectoryFilter = new DetectExcludedDirectoryFilter(excludedDirectories);
File root = new File("path/to/root");
File subDir1 = new File(root, "subDir1");
File subDir2 = new File(root, "subDir2");
File deepSubDir2 = new File(subDir1, "subDir2");
assertFalse(detectExcludedDirectoryFilter.isExcluded(root));
assertFalse(detectExcludedDirectoryFilter.isExcluded(subDir1));
assertFalse(detectExcludedDirectoryFilter.isExcluded(subDir2));
assertTrue(detectExcludedDirectoryFilter.isExcluded(deepSubDir2));
}
use of com.synopsys.integration.detect.util.finder.DetectExcludedDirectoryFilter in project synopsys-detect by blackducksoftware.
the class DetectConfigurationFactory method createDetectorFinderOptions.
public DetectorFinderOptions createDetectorFinderOptions() {
// Normal settings
Integer maxDepth = detectConfiguration.getValue(DetectProperties.DETECT_DETECTOR_SEARCH_DEPTH);
DetectExcludedDirectoryFilter fileFilter = new DetectExcludedDirectoryFilter(collectDirectoryExclusions(DefaultDetectorSearchExcludedDirectories.getDirectoryNames()));
return new DetectorFinderOptions(fileFilter, maxDepth, getFollowSymLinks());
}
Aggregations