use of com.synopsys.integration.detector.rule.DetectorRuleSetBuilder in project synopsys-detect by blackducksoftware.
the class DetectorRuleSetEvaluatorTest method nestableExceptByDetectorType.
@Test
public void nestableExceptByDetectorType() {
DetectorRuleSetBuilder ruleSet = new DetectorRuleSetBuilder();
DetectorRule workspaceRule = ruleSet.addDetector(DetectorType.XCODE, "Xcode Workspace", XcodeWorkspaceDetectable.class, (e) -> null).defaults().notSelfTypeNestable().build();
DetectorRule projectRule = ruleSet.addDetector(DetectorType.XCODE, "Xcode Project", XcodeProjectDetectable.class, (e) -> null).defaults().notSelfTypeNestable().build();
// XCODE applied at depth 0, we are now scanning a folder at depth 2.
Set<DetectorRule> appliedToParent = Sets.newHashSet(workspaceRule);
Set<DetectorRule> appliedSoFar = Sets.newHashSet();
SearchEnvironment searchEnvironment = new SearchEnvironment(2, (d) -> true, false, false, appliedToParent, appliedSoFar);
DetectorResult result = new DetectorRuleSetEvaluator().evaluateSearchable(ruleSet.build(), projectRule, searchEnvironment);
Assertions.assertEquals(NotSelfTypeNestableDetectorResult.class, result.getClass());
}
use of com.synopsys.integration.detector.rule.DetectorRuleSetBuilder in project synopsys-detect by blackducksoftware.
the class DetectorRuleFactory method createBuildlessRules.
private DetectorRuleSet createBuildlessRules(DetectDetectableFactory detectableFactory) {
DetectorRuleSetBuilder ruleSet = new DetectorRuleSetBuilder();
ruleSet.addDetector(DetectorType.CARGO, "Cargo", CargoDetectable.class, detectableFactory::createCargoDetectable).defaults().build();
ruleSet.addDetector(DetectorType.CARTHAGE, "Carthage", CarthageDetectable.class, detectableFactory::createCarthageDetectable).defaults().build();
ruleSet.addDetector(DetectorType.COCOAPODS, "Pod Lock", PodlockDetectable.class, detectableFactory::createPodLockDetectable).defaults().build();
ruleSet.addDetector(DetectorType.SWIFT, "Swift Package Resolved", SwiftPackageResolvedDetectable.class, detectableFactory::createSwiftPackageResolvedDetectable).defaults().notNestableBeneath(DetectorType.XCODE).build();
ruleSet.addDetector(DetectorType.PACKAGIST, "Packrat Lock", PackratLockDetectable.class, detectableFactory::createPackratLockDetectable).defaults().build();
ruleSet.addDetector(DetectorType.DART, "Dart Pub Spec", DartPubSpecLockDetectable.class, detectableFactory::createDartPubSpecLockDetectable).defaults().build();
ruleSet.addDetector(DetectorType.GO_DEP, "Go Lock", GoDepLockDetectable.class, detectableFactory::createGoLockDetectable).defaults().build();
ruleSet.addDetector(DetectorType.GO_VNDR, "Go Vndr", GoVndrDetectable.class, detectableFactory::createGoVndrDetectable).defaults().build();
ruleSet.addDetector(DetectorType.GO_VENDOR, "Go Vendor", GoVendorDetectable.class, detectableFactory::createGoVendorDetectable).defaults().build();
ruleSet.addDetector(DetectorType.GRADLE, "Gradle Project Inspector", GradleProjectInspectorDetectable.class, detectableFactory::createGradleProjectInspectorDetectable).defaults().build();
ruleSet.addDetector(DetectorType.GO_GRADLE, "Go Gradle", GoGradleDetectable.class, detectableFactory::createGoGradleDetectable).defaults().build();
ruleSet.addDetector(DetectorType.IVY, "Ivy Parse", IvyParseDetectable.class, detectableFactory::createIvyParseDetectable).defaultLock().build();
ruleSet.addDetector(DetectorType.MAVEN, "Maven Pom Parse", MavenParseDetectable.class, detectableFactory::createMavenParseDetectable).defaults().build();
ruleSet.addDetector(DetectorType.MAVEN, "Maven Project Inspector", MavenProjectInspectorDetectable.class, detectableFactory::createMavenProjectInspectorDetectable).defaults().build();
DetectorRule<?> pipfileLock = ruleSet.addDetector(DetectorType.PIP, "Pipfile Lock", PipfileLockDetectable.class, detectableFactory::createPipfileLockDetectable).defaults().build();
DetectorRule<?> poetry = ruleSet.addDetector(DetectorType.POETRY, "Poetry", PoetryDetectable.class, detectableFactory::createPoetryDetectable).defaults().build();
ruleSet.yield(pipfileLock).to(poetry);
DetectorRule<?> yarnLock = ruleSet.addDetector(DetectorType.YARN, "Yarn Lock", YarnLockDetectable.class, detectableFactory::createYarnLockDetectable).defaults().build();
DetectorRule<?> npmPackageLock = ruleSet.addDetector(DetectorType.NPM, "Package Lock", NpmPackageLockDetectable.class, detectableFactory::createNpmPackageLockDetectable).defaults().build();
DetectorRule<?> npmShrinkwrap = ruleSet.addDetector(DetectorType.NPM, "Shrinkwrap", NpmShrinkwrapDetectable.class, detectableFactory::createNpmShrinkwrapDetectable).defaults().build();
DetectorRule<?> npmPackageJsonParse = ruleSet.addDetector(DetectorType.NPM, "Package Json Parse", NpmPackageJsonParseDetectable.class, detectableFactory::createNpmPackageJsonParseDetectable).defaults().build();
DetectorRule<?> pnpmLock = ruleSet.addDetector(DetectorType.PNPM, "Pnpm Lock", PnpmLockDetectable.class, detectableFactory::createPnpmLockDetectable).defaults().build();
ruleSet.yield(npmPackageLock).to(npmShrinkwrap);
ruleSet.yield(npmPackageJsonParse).to(npmPackageLock);
ruleSet.yield(npmPackageJsonParse).to(npmShrinkwrap);
ruleSet.yield(npmPackageJsonParse).to(yarnLock);
ruleSet.yield(npmPackageLock).to(yarnLock);
ruleSet.yield(npmShrinkwrap).to(yarnLock);
ruleSet.yield(npmPackageJsonParse).to(pnpmLock);
ruleSet.addDetector(DetectorType.NUGET, "NuGet Project Inspector", NugetProjectInspectorDetectable.class, detectableFactory::createNugetParseDetectable).defaults().build();
ruleSet.addDetector(DetectorType.PACKAGIST, "Composer", ComposerLockDetectable.class, detectableFactory::createComposerDetectable).defaults().build();
DetectorRule<?> gemlock = ruleSet.addDetector(DetectorType.RUBYGEMS, "Gemlock", GemlockDetectable.class, detectableFactory::createGemlockDetectable).defaults().build();
DetectorRule<?> gemspec = ruleSet.addDetector(DetectorType.RUBYGEMS, "Gemspec", GemspecParseDetectable.class, detectableFactory::createGemspecParseDetectable).defaults().build();
ruleSet.yield(gemspec).to(gemlock);
ruleSet.addDetector(DetectorType.GIT, "Git Parse", GitParseDetectable.class, detectableFactory::createGitParseDetectable).defaults().build();
return ruleSet.build();
}
use of com.synopsys.integration.detector.rule.DetectorRuleSetBuilder in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method createRuleSet.
private DetectorRuleSet createRuleSet(DetectorRule<GoModCliDetectable> rule) {
DetectorRuleSetBuilder ruleSetBuilder = new DetectorRuleSetBuilder();
ruleSetBuilder.add(rule);
return ruleSetBuilder.build();
}
Aggregations