Search in sources :

Example 16 with MutableMapDependencyGraph

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

the class VndrParser method parseVendorConf.

public DependencyGraph parseVendorConf(final List<String> vendorConfContents) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    // TODO test against moby
    vendorConfContents.forEach(line -> {
        if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
            final String[] parts = line.split(" ");
            final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]);
            final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId);
            graph.addChildToRoot(dependency);
        }
    });
    return graph;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 17 with MutableMapDependencyGraph

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

the class CpanListParser method parse.

public DependencyGraph parse(final List<String> cpanListText, final List<String> directDependenciesText) {
    final Map<String, String> nameVersionMap = createNameVersionMap(cpanListText);
    final List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    for (final String moduleName : directModuleNames) {
        final String version = nameVersionMap.get(moduleName);
        if (null != version) {
            final String name = moduleName.replace("::", "-");
            final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.CPAN, name, version);
            final 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 : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 18 with MutableMapDependencyGraph

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

the class PearParser method createPearDependencyGraphFromList.

DependencyGraph createPearDependencyGraphFromList(final List<String> dependencyList, final List<String> dependencyNames) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    if (dependencyList.size() > 3) {
        final List<String> listing = dependencyList.subList(3, dependencyList.size() - 1);
        listing.forEach(line -> {
            final String[] dependencyInfo = splitIgnoringWhitespace(line, " ");
            final String packageName = dependencyInfo[0].trim();
            final String packageVersion = dependencyInfo[1].trim();
            if (dependencyInfo.length > 0 && dependencyNames.contains(packageName)) {
                final Dependency child = new Dependency(packageName, packageVersion, externalIdFactory.createNameVersionExternalId(Forge.PEAR, packageName, packageVersion));
                graph.addChildToRoot(child);
            }
        });
    }
    return graph;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 19 with MutableMapDependencyGraph

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

the class SbtModuleAggregator method aggregateModules.

public List<SbtDependencyModule> aggregateModules(final List<SbtDependencyModule> modules) {
    final Set<SbtAggregate> aggregates = uniqueAggregates(modules);
    logger.debug("Found unique aggregates: " + aggregates.size());
    return aggregates.stream().map(aggregate -> {
        final SbtDependencyModule aggregated = new SbtDependencyModule();
        aggregated.name = aggregate.name;
        aggregated.version = aggregate.version;
        aggregated.org = aggregate.org;
        final MutableDependencyGraph graph = new MutableMapDependencyGraph();
        aggregated.graph = graph;
        final DependencyGraphCombiner combiner = new DependencyGraphCombiner();
        modules.forEach(module -> {
            if (moduleEqualsAggregate(module, aggregate)) {
                logger.debug("Combining '" + module.name + "' with '" + aggregate.name + "'");
                combiner.addGraphAsChildrenToRoot(graph, module.graph);
            }
        });
        return aggregated;
    }).collect(Collectors.toList());
}
Also used : List(java.util.List) Logger(org.slf4j.Logger) MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Collectors(java.util.stream.Collectors) DependencyGraphCombiner(com.synopsys.integration.bdio.graph.DependencyGraphCombiner) MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) DependencyGraphCombiner(com.synopsys.integration.bdio.graph.DependencyGraphCombiner)

Example 20 with MutableMapDependencyGraph

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

the class YarnListParser method parseYarnList.

public DependencyGraph parseYarnList(final List<String> yarnLockText, final List<String> yarnListAsList) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    final DependencyHistory history = new DependencyHistory();
    final Map<String, String> yarnLockVersionMap = yarnLockParser.getYarnLockResolvedVersionMap(yarnLockText);
    for (final String line : yarnListAsList) {
        final String lowerCaseLine = line.toLowerCase().trim();
        final String cleanedLine = line.replaceAll(NTH_DEPENDENCY_PREFIX, "").replaceAll(INNER_LEVEL_CHARACTER, "").replaceAll(LAST_DEPENDENCY_PREFIX, "");
        if (!cleanedLine.contains("@") || lowerCaseLine.startsWith("yarn list") || lowerCaseLine.startsWith("done in") || lowerCaseLine.startsWith("warning")) {
            continue;
        }
        final Dependency dependency = parseDependencyFromLine(cleanedLine, yarnLockVersionMap);
        final int lineLevel = getLineLevel(cleanedLine);
        try {
            history.clearDependenciesDeeperThan(lineLevel);
        } catch (final IllegalStateException e) {
            logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage()));
        }
        if (history.isEmpty()) {
            graph.addChildToRoot(dependency);
        } else {
            graph.addChildWithParents(dependency, history.getLastDependency());
        }
        history.add(dependency);
    }
    return graph;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) DependencyHistory(com.blackducksoftware.integration.hub.detect.util.DependencyHistory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)21 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)17 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)12 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)11 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)8 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 DependencyHistory (com.blackducksoftware.integration.hub.detect.util.DependencyHistory)4 List (java.util.List)4 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 DependencyGraphCombiner (com.synopsys.integration.bdio.graph.DependencyGraphCombiner)2 Forge (com.synopsys.integration.bdio.model.Forge)2 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)2 NameVersion (com.synopsys.integration.util.NameVersion)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2