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;
}
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;
}
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();
}
}
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()));
}
}
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);
}
Aggregations