Search in sources :

Example 1 with DependencyGraph

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

the class PearParser method parsePearDependencyList.

public DependencyGraph parsePearDependencyList(final ExecutableOutput pearListing, final ExecutableOutput pearDependencies) {
    DependencyGraph graph = new MutableMapDependencyGraph();
    if (StringUtils.isNotBlank(pearDependencies.getErrorOutput()) || StringUtils.isNotBlank(pearListing.getErrorOutput())) {
        logger.error("There was an error during execution.");
        if (StringUtils.isNotBlank(pearListing.getErrorOutput())) {
            logger.error("Pear list error: ");
            logger.error(pearListing.getErrorOutput());
        }
        if (StringUtils.isNotBlank(pearDependencies.getErrorOutput())) {
            logger.error("Pear package-dependencies error: ");
            logger.error(pearDependencies.getErrorOutput());
        }
    } else if (!(pearDependencies.getStandardOutputAsList().size() > 0) || !(pearListing.getStandardOutputAsList().size() > 0)) {
        logger.error("No information retrieved from running pear commands");
    } else {
        final List<String> nameList = findDependencyNames(pearDependencies.getStandardOutputAsList());
        graph = createPearDependencyGraphFromList(pearListing.getStandardOutputAsList(), nameList);
    }
    return graph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with DependencyGraph

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

the class NugetInspectorPackager method createDetectCodeLocationFromNugetContainer.

private Optional<NugetParseResult> createDetectCodeLocationFromNugetContainer(final NugetContainer nugetContainer) {
    final NugetParseResult parseResult;
    String projectName = "";
    String projectVersionName = "";
    if (NugetContainerType.SOLUTION == nugetContainer.type) {
        projectName = nugetContainer.name;
        projectVersionName = nugetContainer.version;
        final List<DetectCodeLocation> codeLocations = new ArrayList<>();
        for (final NugetContainer container : nugetContainer.children) {
            final NugetDependencyNodeBuilder builder = new NugetDependencyNodeBuilder(externalIdFactory);
            builder.addPackageSets(container.packages);
            final DependencyGraph children = builder.createDependencyGraph(container.dependencies);
            final String sourcePath = container.sourcePath;
            if (StringUtils.isBlank(projectVersionName)) {
                projectVersionName = container.version;
            }
            final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.NUGET, sourcePath, externalIdFactory.createNameVersionExternalId(Forge.NUGET, projectName, projectVersionName), children).build();
            codeLocations.add(codeLocation);
        }
        parseResult = new NugetParseResult(projectName, projectVersionName, codeLocations);
    } else if (NugetContainerType.PROJECT == nugetContainer.type) {
        projectName = nugetContainer.name;
        projectVersionName = nugetContainer.version;
        final String sourcePath = nugetContainer.sourcePath;
        final NugetDependencyNodeBuilder builder = new NugetDependencyNodeBuilder(externalIdFactory);
        builder.addPackageSets(nugetContainer.packages);
        final DependencyGraph children = builder.createDependencyGraph(nugetContainer.dependencies);
        final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.NUGET, sourcePath, externalIdFactory.createNameVersionExternalId(Forge.NUGET, projectName, projectVersionName), children).build();
        parseResult = new NugetParseResult(projectName, projectVersionName, codeLocation);
    } else {
        parseResult = null;
    }
    return Optional.ofNullable(parseResult);
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) NugetContainer(com.blackducksoftware.integration.hub.detect.detector.nuget.model.NugetContainer) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph)

Example 3 with DependencyGraph

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

the class GemlockNodeParserTest method testParsingEqualsGemfileLock.

@Test
public void testParsingEqualsGemfileLock() {
    final String text = testUtils.getResourceAsUTF8String("/rubygems/Gemfile_equals_version.lock");
    final List<String> gemfileLockContents = Arrays.asList(text.split("\n"));
    final GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
    Dependency bundler = dependencyGraph.getDependency(new ExternalIdFactory().createNameVersionExternalId(Forge.RUBYGEMS, "bundler", "1.11.2"));
    assertNotNull(bundler);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 4 with DependencyGraph

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

the class GemlockNodeParserTest method testMissingVersionsGemfileLock.

@Test
public void testMissingVersionsGemfileLock() {
    final String text = testUtils.getResourceAsUTF8String("/rubygems/Gemfile_missing_versions.lock");
    final List<String> gemfileLockContents = Arrays.asList(text.split("\n"));
    final GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
    Dependency newrelic_rpm = dependencyGraph.getDependency(new ExternalIdFactory().createNameVersionExternalId(Forge.RUBYGEMS, "newrelic_rpm", ""));
    assertNotNull(newrelic_rpm);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 5 with DependencyGraph

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

the class YarnListParserTest method parseYarnListTest.

@Test
public void parseYarnListTest() {
    final List<String> designedYarnLock = new ArrayList<>();
    designedYarnLock.add("async@~0.9.0:");
    designedYarnLock.add("  version \"0.9.2\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d\"");
    designedYarnLock.add("  dependencies:");
    designedYarnLock.add("    minimist \"0.0.8\"");
    designedYarnLock.add("");
    designedYarnLock.add("minimist@0.0.8:");
    designedYarnLock.add("  version \"0.0.8\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d\"");
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final YarnLockParser yarnLockParser = new YarnLockParser();
    final YarnListParser yarnListParser = new YarnListParser(externalIdFactory, yarnLockParser);
    final String yarnListText = testUtil.getResourceAsUTF8String("/yarn/yarn.list.txt");
    final DependencyGraph dependencyGraph = yarnListParser.parseYarnList(designedYarnLock, Arrays.asList(yarnListText.split(System.lineSeparator())));
    DependencyGraphResourceTestUtil.assertGraph("/yarn/list_expected_graph.json", dependencyGraph);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Aggregations

DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)46 Test (org.junit.Test)26 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)21 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)19 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)15 ArrayList (java.util.ArrayList)13 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)12 File (java.io.File)9 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)6 Forge (com.synopsys.integration.bdio.model.Forge)5 ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)4 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)4 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)3 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)3 SimpleBdioDocument (com.synopsys.integration.bdio.model.SimpleBdioDocument)3 NameDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)3 NameVersion (com.synopsys.integration.util.NameVersion)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Executable (com.blackducksoftware.integration.hub.detect.util.executable.Executable)2