Search in sources :

Example 36 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class PipfileLockDependencyTransformer method transform.

public DependencyGraph transform(List<PipfileLockDependency> dependencies) {
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    dependencies.stream().map(this::createDependency).forEach(dependencyGraph::addChildToRoot);
    return dependencyGraph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 37 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class PubDepsParser method parse.

public DependencyGraph parse(List<String> pubDepsOutput) {
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    Map<String, String> resolvedVersions = resolveVersionsOfDependencies(pubDepsOutput);
    parseLines(pubDepsOutput, resolvedVersions, dependencyGraph);
    return dependencyGraph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 38 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class PubSpecLockParser method parse.

public DependencyGraph parse(List<String> pubSpecLockLines) {
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    // TODO- do we even need these booleans? will there be cases we run into name and version keys that we don't want to read/don't correspond to a dependency?
    boolean inPackages = false;
    boolean inDescription = false;
    Optional<String> dependencyName = Optional.empty();
    for (String line : pubSpecLockLines) {
        String trimmedLine = StringUtils.trimToEmpty(line);
        if (StringUtils.isBlank(trimmedLine)) {
            continue;
        } else if (trimmedLine.equals(PACKAGES_SECTION_HEADER)) {
            inPackages = true;
        } else if (inPackages && trimmedLine.equals(DESCRIPTION_SECTION_HEADER)) {
            inDescription = true;
        } else if (inDescription && trimmedLine.startsWith(NAME_LINE_KEY)) {
            dependencyName = parseValueFromLine(trimmedLine, NAME_LINE_KEY);
        } else if (inPackages && trimmedLine.startsWith(VERSION_LINE_KEY)) {
            Optional<String> dependencyVersion = parseValueFromLine(trimmedLine, VERSION_LINE_KEY);
            if (dependencyName.isPresent() && dependencyVersion.isPresent()) {
                dependencyGraph.addChildToRoot(DependencyCreator.nameVersion(Forge.DART, dependencyName.get(), dependencyVersion.get()));
                // After process dependency, reset name and version variables
                dependencyName = Optional.empty();
            }
        }
    }
    return dependencyGraph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 39 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class CpanListParser method parse.

// TODO: In a transformer
public DependencyGraph parse(List<String> cpanListText, List<String> directDependenciesText) {
    Map<String, String> nameVersionMap = createNameVersionMap(cpanListText);
    // Lazy builder.
    List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
    DependencyGraph graph = new BasicDependencyGraph();
    for (String moduleName : directModuleNames) {
        String version = nameVersionMap.get(moduleName);
        if (null != version) {
            String name = moduleName.replace("::", "-");
            ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.CPAN, name, version);
            Dependency dependency = new Dependency(name, version, externalId);
            graph.addChildToRoot(dependency);
        } else {
            logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
        }
    }
    return graph;
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 40 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class GoLockParser method parseDepLock.

public DependencyGraph parseDepLock(InputStream depLockInputStream) {
    DependencyGraph graph = new BasicDependencyGraph();
    GoLock goLock = new Toml().read(depLockInputStream).to(GoLock.class);
    if (goLock.projects != null) {
        for (Project project : goLock.projects) {
            if (project != null) {
                String projectName = project.getName();
                String projectVersion = Optional.ofNullable(StringUtils.stripToNull(project.getVersion())).orElse(project.getRevision());
                project.getPackages().stream().map(packageName -> createDependencyName(projectName, packageName)).map(dependencyName -> createGoDependency(dependencyName, projectVersion)).forEach(graph::addChildToRoot);
            }
        }
    }
    return graph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Forge(com.synopsys.integration.bdio.model.Forge) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Toml(com.moandjiezana.toml.Toml) Optional(java.util.Optional) Project(com.synopsys.integration.detectable.detectables.go.godep.model.Project) GoLock(com.synopsys.integration.detectable.detectables.go.godep.model.GoLock) StringUtils(org.apache.commons.lang3.StringUtils) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) InputStream(java.io.InputStream) Project(com.synopsys.integration.detectable.detectables.go.godep.model.Project) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) GoLock(com.synopsys.integration.detectable.detectables.go.godep.model.GoLock) Toml(com.moandjiezana.toml.Toml)

Aggregations

BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)43 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)38 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)26 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)16 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 List (java.util.List)7 Forge (com.synopsys.integration.bdio.model.Forge)6 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)5 ArrayList (java.util.ArrayList)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 File (java.io.File)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 Gson (com.google.gson.Gson)3 NotNull (org.jetbrains.annotations.NotNull)3 GraphEdge (com.paypal.digraph.parser.GraphEdge)2 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)2 DependencyHistory (com.synopsys.integration.detectable.detectable.util.DependencyHistory)2 Extraction (com.synopsys.integration.detectable.extraction.Extraction)2