use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class SbtPackager method makeModuleAggregate.
private List<SbtDependencyModule> makeModuleAggregate(final List<File> reportFiles, final String include, final String exclude) throws SAXException, IOException, ParserConfigurationException {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final SbtReportParser parser = new SbtReportParser();
final SbtDependencyResolver resolver = new SbtDependencyResolver(externalIdFactory);
final ExcludedIncludedFilter filter = new ExcludedIncludedFilter(exclude, include);
final SbtModuleAggregator aggregator = new SbtModuleAggregator();
final List<SbtDependencyModule> modules = new ArrayList<>();
for (final File reportFile : reportFiles) {
final Document xml = builder.parse(reportFile);
logger.debug(String.format("Parsing SBT report file: %s", reportFile.getCanonicalPath()));
final SbtReport report = parser.parseReportFromXml(xml);
final SbtDependencyModule tree = resolver.resolveReport(report);
modules.add(tree);
}
final List<SbtDependencyModule> includedModules = modules.stream().filter(module -> filter.shouldInclude(module.configuration)).collect(Collectors.toList());
if (modules.size() <= 0) {
logger.warn("No sbt configurations were found in report folder.");
return null;
} else if (includedModules.size() <= 0) {
logger.warn(String.format("Although %s configs were found, none were included.", modules.size()));
return null;
}
return aggregator.aggregateModules(includedModules);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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.externalid.ExternalIdFactory 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.externalid.ExternalIdFactory 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.externalid.ExternalIdFactory 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);
}
Aggregations