use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class Rebar3TreeParser method parseRebarTreeOutput.
public RebarParseResult parseRebarTreeOutput(List<String> dependencyTreeOutput) {
DependencyGraph graph = new BasicDependencyGraph();
DependencyHistory history = new DependencyHistory();
Dependency project = null;
for (String line : dependencyTreeOutput) {
if (!line.contains(HORIZONTAL_SEPARATOR_CHARACTER)) {
continue;
}
Dependency currentDependency = createDependencyFromLine(line);
int lineLevel = getDependencyLevelFromLine(line);
try {
history.clearDependenciesDeeperThan(lineLevel);
} catch (IllegalStateException e) {
logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage()));
}
if (history.isEmpty() && isProject(line)) {
project = currentDependency;
} else if (history.getLastDependency().equals(project)) {
graph.addChildToRoot(currentDependency);
} else if (history.isEmpty()) {
graph.addChildToRoot(currentDependency);
} else {
graph.addChildWithParents(currentDependency, history.getLastDependency());
}
history.add(currentDependency);
}
if (project == null) {
CodeLocation codeLocation = new CodeLocation(graph);
return new RebarParseResult(codeLocation);
} else {
CodeLocation codeLocation = new CodeLocation(graph, project.getExternalId());
return new RebarParseResult(new NameVersion(project.getName(), project.getVersion()), codeLocation);
}
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class NugetDependencyNodeBuilder method createDependencyGraph.
public DependencyGraph createDependencyGraph(List<NugetPackageId> packageDependencies) {
DependencyGraph graph = new BasicDependencyGraph();
for (NugetPackageSet packageSet : packageSets) {
if (packageSet.dependencies != null) {
for (NugetPackageId id : packageSet.dependencies) {
if (packageSet.packageId != null) {
graph.addParentWithChild(convertPackageId(packageSet.packageId), convertPackageId(id));
}
}
}
}
packageDependencies.stream().map(this::convertPackageId).forEach(graph::addChildToRoot);
return graph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PnpmYamlTransformer method generateCodeLocation.
public CodeLocation generateCodeLocation(File sourcePath, PnpmProjectPackage projectPackage, @Nullable String reportingProjectPackagePath, @Nullable NameVersion projectNameVersion, @Nullable Map<String, PnpmPackageInfo> packageMap, PnpmLinkedPackageResolver linkedPackageResolver) throws IntegrationException {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
List<String> rootPackageIds = extractRootPackageIds(projectPackage, reportingProjectPackagePath, linkedPackageResolver);
buildGraph(dependencyGraph, rootPackageIds, packageMap, linkedPackageResolver, reportingProjectPackagePath);
if (projectNameVersion != null) {
return new CodeLocation(dependencyGraph, ExternalId.FACTORY.createNameVersionExternalId(Forge.NPMJS, projectNameVersion.getName(), projectNameVersion.getVersion()), sourcePath);
}
return new CodeLocation(dependencyGraph, sourcePath);
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PipInspectorTreeParser method parse.
public Optional<NameVersionCodeLocation> parse(List<String> pipInspectorOutputAsList, String sourcePath) {
NameVersionCodeLocation parseResult = null;
DependencyGraph graph = new BasicDependencyGraph();
DependencyHistory history = new DependencyHistory();
Dependency project = null;
int unResolvedPackageCount = 0;
for (String line : pipInspectorOutputAsList) {
String trimmedLine = StringUtils.trimToEmpty(line);
if (StringUtils.isEmpty(trimmedLine) || !trimmedLine.contains(SEPARATOR) || trimmedLine.startsWith(UNKNOWN_REQUIREMENTS_PREFIX) || trimmedLine.startsWith(UNPARSEABLE_REQUIREMENTS_PREFIX) || trimmedLine.startsWith(UNKNOWN_PACKAGE_PREFIX)) {
boolean wasUnresolved = parseErrorsFromLine(trimmedLine);
if (wasUnresolved) {
unResolvedPackageCount++;
}
continue;
}
Dependency currentDependency = parseDependencyFromLine(trimmedLine, sourcePath);
adjustForIndentLevel(history, line);
project = addDependencyToGraph(graph, history, project, currentDependency);
history.add(currentDependency);
}
adviseIfUnresolvedPackages(unResolvedPackageCount);
if (project != null) {
CodeLocation codeLocation = new CodeLocation(graph, project.getExternalId());
parseResult = new NameVersionCodeLocation(project.getName(), project.getVersion(), codeLocation);
}
return Optional.ofNullable(parseResult);
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PipenvTransformer method transform.
public CodeLocation transform(String projectName, String projectVersionName, PipFreeze pipFreeze, PipenvGraph pipenvGraph, boolean includeOnlyProjectTree) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
for (PipenvGraphEntry entry : pipenvGraph.getEntries()) {
Dependency entryDependency = nameVersionToDependency(entry.getName(), entry.getVersion(), pipFreeze);
List<Dependency> children = addDependenciesToGraph(entry.getChildren(), dependencyGraph, pipFreeze);
if (matchesProject(entryDependency, projectName, projectVersionName)) {
// The project appears as an entry, we don't want the project to be a dependency of itself.
dependencyGraph.addChildrenToRoot(children);
} else if (!includeOnlyProjectTree) {
// Only add non-project matches if we are not project tree only.
dependencyGraph.addChildToRoot(entryDependency);
dependencyGraph.addParentWithChildren(entryDependency, children);
}
}
ExternalId projectExternalId = externalIdFactory.createNameVersionExternalId(Forge.PYPI, projectName, projectVersionName);
return new CodeLocation(dependencyGraph, projectExternalId);
}
Aggregations