use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class AggregateBdioCreator method createAggregateDependency.
private Dependency createAggregateDependency(File sourcePath, final DetectCodeLocation codeLocation) {
String name = null;
String version = null;
try {
name = codeLocation.getExternalId().name;
version = codeLocation.getExternalId().version;
} catch (final Exception e) {
logger.warn("Failed to get name or version to use in the wrapper for a code location.", e);
}
final ExternalId original = codeLocation.getExternalId();
final String codeLocationSourcePath = codeLocation.getSourcePath();
final String bomToolType = codeLocation.getCodeLocationType().toString();
final String relativePath = FileNameUtils.relativize(sourcePath.getAbsolutePath(), codeLocationSourcePath);
final List<String> externalIdPieces = new ArrayList<>();
externalIdPieces.addAll(Arrays.asList(original.getExternalIdPieces()));
externalIdPieces.add(relativePath);
externalIdPieces.add(bomToolType);
final String[] pieces = externalIdPieces.toArray(new String[externalIdPieces.size()]);
return new Dependency(name, version, new ExternalIdFactory().createModuleNamesExternalId(original.forge, pieces));
}
use of com.synopsys.integration.bdio.model.dependency.Dependency 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);
}
use of com.synopsys.integration.bdio.model.dependency.Dependency 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);
}
use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class GoVendorJsonParser method parseVendorJson.
public DependencyGraph parseVendorJson(final Gson gson, final String vendorJsonContents) {
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
GoVendorJsonData vendorJsonData = gson.fromJson(vendorJsonContents, GoVendorJsonData.class);
logger.trace(String.format("vendorJsonData: %s", vendorJsonData));
for (GoVendorJsonPackageData pkg : vendorJsonData.getPackages()) {
if (StringUtils.isNotBlank(pkg.getPath()) && StringUtils.isNotBlank(pkg.getRevision())) {
final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, pkg.getPath(), pkg.getRevision());
final Dependency dependency = new Dependency(pkg.getPath(), pkg.getRevision(), dependencyExternalId);
logger.trace(String.format("dependency: %s", dependency.externalId.toString()));
graph.addChildToRoot(dependency);
} else {
logger.debug(String.format("Omitting package path:'%s', revision:'%s' (one or both of path, revision is/are missing)", pkg.getPath(), pkg.getRevision()));
}
}
return graph;
}
use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class GradleReportLine method createDependencyNode.
public Dependency createDependencyNode(final ExternalIdFactory externalIdFactory) {
if (!originalLine.contains(COMPONENT_PREFIX)) {
return null;
}
String cleanedOutput = StringUtils.trimToEmpty(originalLine);
cleanedOutput = cleanedOutput.substring(cleanedOutput.indexOf(COMPONENT_PREFIX) + COMPONENT_PREFIX.length());
if (cleanedOutput.endsWith(SEEN_ELSEWHERE_SUFFIX)) {
final int lastSeenElsewhereIndex = cleanedOutput.lastIndexOf(SEEN_ELSEWHERE_SUFFIX);
cleanedOutput = cleanedOutput.substring(0, lastSeenElsewhereIndex);
}
// we might need to modify the returned list, so it needs to be an actual ArrayList
List<String> gavPieces = new ArrayList<>(Arrays.asList(cleanedOutput.split(":")));
if (cleanedOutput.contains(WINNING_INDICATOR)) {
// WINNING_INDICATOR can point to an entire GAV not just a version
final String winningSection = cleanedOutput.substring(cleanedOutput.indexOf(WINNING_INDICATOR) + WINNING_INDICATOR.length());
if (winningSection.contains(":")) {
gavPieces = Arrays.asList(winningSection.split(":"));
} else {
// the WINNING_INDICATOR is not always preceded by a : so if isn't, we need to clean up from the original split
if (gavPieces.get(1).contains(WINNING_INDICATOR)) {
final String withoutWinningIndicator = gavPieces.get(1).substring(0, gavPieces.get(1).indexOf(WINNING_INDICATOR));
gavPieces.set(1, withoutWinningIndicator);
// since there was no : we don't have a gav piece for version yet
gavPieces.add("");
}
gavPieces.set(2, winningSection);
}
}
if (gavPieces.size() != 3) {
logger.error(String.format("The line can not be reasonably split in to the neccessary parts: %s", originalLine));
return null;
}
final String group = gavPieces.get(0);
final String artifact = gavPieces.get(1);
final String version = gavPieces.get(2);
final Dependency dependency = new Dependency(artifact, version, externalIdFactory.createMavenExternalId(group, artifact, version));
return dependency;
}
Aggregations