Search in sources :

Example 31 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class NugetDependencyNodeBuilder method convertPackageId.

private Dependency convertPackageId(final NugetPackageId id) {
    final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.NUGET, id.name, id.version);
    final Dependency node = new Dependency(id.name, id.version, externalId);
    return node;
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 32 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class ClangExtractor method getBdioComponents.

private List<Dependency> getBdioComponents(final ClangLinuxPackageManager pkgMgr, final String name, final String version, final String arch) {
    final List<Dependency> dependencies = new ArrayList<>();
    final String externalId = String.format("%s/%s/%s", name, version, arch);
    logger.trace(String.format("Constructed externalId: %s", externalId));
    for (final Forge forge : pkgMgr.getForges()) {
        final ExternalId extId = bdioFactory.createArchitectureExternalId(forge, name, version, arch);
        final Dependency dep = bdioFactory.createDependency(name, version, extId);
        logger.debug(String.format("forge: %s: adding %s version %s as child to dependency node tree; externalId: %s", forge.getName(), dep.name, dep.version, dep.externalId.createBdioId()));
        dependencies.add(dep);
    }
    return dependencies;
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ArrayList(java.util.ArrayList) Forge(com.synopsys.integration.bdio.model.Forge) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 33 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class ClangExtractor method extract.

public Extraction extract(final ClangLinuxPackageManager pkgMgr, final File givenDir, final int depth, final ExtractionId extractionId, final File jsonCompilationDatabaseFile) {
    try {
        logger.info(String.format("Analyzing %s", jsonCompilationDatabaseFile.getAbsolutePath()));
        final File rootDir = fileFinder.findContainingDir(givenDir, depth);
        final File outputDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
        logger.debug(String.format("extract() called; compileCommandsJsonFilePath: %s", jsonCompilationDatabaseFile.getAbsolutePath()));
        final Set<File> unManagedDependencyFiles = ConcurrentHashMap.newKeySet(64);
        final List<CompileCommand> compileCommands = CompileCommandsJsonFile.parseJsonCompilationDatabaseFile(gson, jsonCompilationDatabaseFile);
        final List<Dependency> bdioComponents = compileCommands.parallelStream().flatMap(compileCommandToDependencyFilePathsConverter(outputDirectory)).collect(Collectors.toSet()).parallelStream().filter(StringUtils::isNotBlank).map(File::new).filter(fileIsNewPredicate()).flatMap(dependencyFileToLinuxPackagesConverter(rootDir, unManagedDependencyFiles, pkgMgr)).collect(Collectors.toSet()).parallelStream().flatMap(linuxPackageToBdioComponentsConverter(pkgMgr)).collect(Collectors.toList());
        final DetectCodeLocation detectCodeLocation = codeLocationAssembler.generateCodeLocation(pkgMgr.getDefaultForge(), rootDir, bdioComponents);
        logSummary(bdioComponents, unManagedDependencyFiles);
        return new Extraction.Builder().success(detectCodeLocation).build();
    } catch (final Exception e) {
        return new Extraction.Builder().exception(e).build();
    }
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File)

Example 34 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class ClangExtractor method logSummary.

private void logSummary(final List<Dependency> bdioComponents, final Set<File> unManagedDependencyFiles) {
    logger.info(String.format("Number of unique component external IDs generated: %d", bdioComponents.size()));
    if (logger.isDebugEnabled()) {
        for (final Dependency bdioComponent : bdioComponents) {
            logger.info(String.format("\tComponent: %s", bdioComponent.externalId));
        }
    }
    logger.info("Dependency files outside the build directory that were not recognized by the package manager:");
    for (final File unMatchedDependencyFile : unManagedDependencyFiles) {
        logger.info(String.format("\t%s", unMatchedDependencyFile.getAbsolutePath()));
    }
}
Also used : Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File)

Example 35 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class Rebar3TreeParser method parseRebarTreeOutput.

public RebarParseResult parseRebarTreeOutput(final List<String> dependencyTreeOutput, final String sourcePath) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    final DependencyHistory history = new DependencyHistory();
    Dependency project = null;
    for (final String line : dependencyTreeOutput) {
        if (!line.contains(HORIZONTAL_SEPARATOR_CHARACTER)) {
            continue;
        }
        final Dependency currentDependency = createDependencyFromLine(line);
        final int lineLevel = getDependencyLevelFromLine(line);
        try {
            history.clearDependenciesDeeperThan(lineLevel);
        } catch (final 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) {
        final ExternalId projectExternalId = externalIdFactory.createPathExternalId(Forge.HEX, sourcePath);
        project = new Dependency("", "", projectExternalId);
    }
    final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.HEX, project.name, project.version);
    final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.HEX, sourcePath, externalId, graph).build();
    return new RebarParseResult(project.name, project.version, codeLocation);
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) DependencyHistory(com.blackducksoftware.integration.hub.detect.util.DependencyHistory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)46 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)23 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)12 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)11 Test (org.junit.Test)11 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)10 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)9 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 File (java.io.File)5 DependencyHistory (com.blackducksoftware.integration.hub.detect.util.DependencyHistory)4 ArrayList (java.util.ArrayList)3 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)2 Gson (com.google.gson.Gson)2 Forge (com.synopsys.integration.bdio.model.Forge)2 NpmDependency (com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmDependency)1 PackageLockDependency (com.blackducksoftware.integration.hub.detect.detector.npm.model.PackageLockDependency)1 DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1 DetectCodeLocationType (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocationType)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1