use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class GemspecParseExtractor method extract.
public Extraction extract(File gemspec) {
try (InputStream inputStream = new FileInputStream(gemspec)) {
DependencyGraph dependencyGraph = gemspecParser.parse(inputStream);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).build();
} catch (IOException e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PipInspectorExtractor method extract.
public Extraction extract(File directory, ExecutableTarget pythonExe, ExecutableTarget pipExe, File pipInspector, File setupFile, List<Path> requirementFilePaths, String providedProjectName) {
toolVersionLogger.log(directory, pythonExe);
toolVersionLogger.log(directory, pipExe);
Extraction extractionResult;
try {
String projectName = getProjectName(directory, pythonExe, setupFile, providedProjectName);
List<CodeLocation> codeLocations = new ArrayList<>();
String projectVersion = null;
List<Path> requirementsPaths = new ArrayList<>();
if (requirementFilePaths.isEmpty()) {
requirementsPaths.add(null);
} else {
requirementsPaths.addAll(requirementFilePaths);
}
for (Path requirementFilePath : requirementsPaths) {
List<String> inspectorOutput = runInspector(directory, pythonExe, pipInspector, projectName, requirementFilePath);
Optional<NameVersionCodeLocation> result = pipInspectorTreeParser.parse(inspectorOutput, directory.toString());
if (result.isPresent()) {
codeLocations.add(result.get().getCodeLocation());
String potentialProjectVersion = result.get().getProjectVersion();
if (projectVersion == null && StringUtils.isNotBlank(potentialProjectVersion)) {
projectVersion = potentialProjectVersion;
}
}
}
if (codeLocations.isEmpty()) {
extractionResult = new Extraction.Builder().failure("The Pip Inspector tree parse failed to produce output.").build();
} else {
extractionResult = new Extraction.Builder().success(codeLocations).projectName(projectName).projectVersion(projectVersion).build();
}
} catch (Exception e) {
extractionResult = new Extraction.Builder().exception(e).build();
}
return extractionResult;
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorFunctionalTest method extractWithDevDependencies.
@Test
void extractWithDevDependencies() {
Extraction extraction = createExtractor(NpmDependencyType.PEER).extract(packageJsonInputStream);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasRootDependency(testDevDep1);
graphAssert.hasRootDependency(testDevDep2);
graphAssert.hasNoDependency(testPeerDep1);
graphAssert.hasNoDependency(testPeerDep2);
graphAssert.hasRootSize(4);
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorFunctionalTest method extractWithNoDevDependencies.
@Test
void extractWithNoDevDependencies() {
Extraction extraction = createExtractor(NpmDependencyType.PEER, NpmDependencyType.DEV).extract(packageJsonInputStream);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasNoDependency(testDevDep1);
graphAssert.hasNoDependency(testDevDep2);
graphAssert.hasNoDependency(testPeerDep1);
graphAssert.hasNoDependency(testPeerDep2);
graphAssert.hasRootSize(2);
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorTest method extractWithNoDevOrPeerDependencies.
@Test
void extractWithNoDevOrPeerDependencies() {
PackageJson packageJson = createPackageJson();
Extraction extraction = createExtractor(NpmDependencyType.DEV, NpmDependencyType.PEER).extract(packageJson);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasNoDependency(testDevDep1);
graphAssert.hasNoDependency(testDevDep2);
graphAssert.hasRootSize(2);
}
Aggregations