use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class GoVndrExtractor method extract.
public Extraction extract(final File directory, final File vndrConfig) {
try {
final VndrParser vndrParser = new VndrParser(externalIdFactory);
final List<String> venderConfContents = Files.readAllLines(vndrConfig.toPath(), StandardCharsets.UTF_8);
logger.debug(venderConfContents.stream().collect(Collectors.joining("\n")));
final DependencyGraph dependencyGraph = vndrParser.parseVendorConf(venderConfContents);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.GOLANG, directory.toString());
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.GO_VNDR, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(codeLocation).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class MavenCodeLocationPackager method createMavenParseResult.
private MavenParseResult createMavenParseResult(final String sourcePath, final String line, final DependencyGraph graph) {
final Dependency dependency = textToProject(line);
if (null != dependency) {
String codeLocationSourcePath = sourcePath;
if (!sourcePath.endsWith(dependency.name)) {
codeLocationSourcePath += "/" + dependency.name;
}
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.MAVEN, codeLocationSourcePath, dependency.externalId, graph).build();
return new MavenParseResult(dependency.name, dependency.version, codeLocation);
}
return null;
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class PodlockExtractor method extract.
public Extraction extract(final File directory, final File podlock) {
String podLockText;
try {
logger.trace(String.format("Reading from the pod lock file %s", podlock.getAbsolutePath()));
podLockText = FileUtils.readFileToString(podlock, StandardCharsets.UTF_8);
logger.debug(podLockText);
logger.trace("Finished reading from the pod lock file.");
} catch (final IOException e) {
return new Extraction.Builder().exception(e).build();
}
DependencyGraph dependencyGraph;
try {
logger.trace("Attempting to create the dependency graph from the pod lock file.");
dependencyGraph = podlockParser.extractDependencyGraph(podLockText);
logger.trace("Finished creating the dependency graph from the pod lock file.");
} catch (final IOException e) {
return new Extraction.Builder().exception(e).build();
}
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.COCOAPODS, directory.toString());
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.COCOAPODS, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(codeLocation).build();
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class RebarParserTest method testParseRebarTreeOutput.
@Test
public void testParseRebarTreeOutput() {
final MutableMapDependencyGraph expectedGraph = new MutableMapDependencyGraph();
final Dependency gitInnerParentDependency = buildDependency("git_inner_parent_dependency", "0.0.2");
final Dependency hexInnerChildDependency = buildDependency("hex_inner_child_dependency", "0.3.0");
final Dependency hexGrandchildDependency = buildDependency("hex_grandchild_dependency", "4.0.0");
final Dependency gitInnerChildDependency = buildDependency("git_inner_child_dependency", "0.5.0");
final Dependency gitGrandchildDependency = buildDependency("git_grandchild_dependency", "6.0.0");
final Dependency gitOuterParentDependency = buildDependency("git_outer_parent_dependency", "0.0.7");
final Dependency gitOuterChildDependency = buildDependency("git_outer_child_dependency", "0.8.0");
expectedGraph.addChildrenToRoot(gitInnerParentDependency, gitOuterParentDependency);
expectedGraph.addChildWithParent(hexInnerChildDependency, gitInnerParentDependency);
expectedGraph.addChildWithParents(hexGrandchildDependency, hexInnerChildDependency);
expectedGraph.addChildWithParent(gitInnerChildDependency, gitInnerParentDependency);
expectedGraph.addChildWithParents(gitGrandchildDependency, gitInnerChildDependency);
expectedGraph.addChildWithParents(gitOuterChildDependency, gitOuterParentDependency);
final DetectCodeLocation codeLocation = build("/hex/dependencyTree.txt");
final DependencyGraph actualGraph = codeLocation.getDependencyGraph();
assertGraph(expectedGraph, actualGraph);
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class NugetInspectorPackagerTest method createCodeLocationDWService.
@Test(timeout = 5000L)
public void createCodeLocationDWService() throws IOException {
final File dependencyNodeFile = new File(getClass().getResource("/nuget/dwCheckApi_inspection_martin.json").getFile());
final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
final NugetInspectorPackager packager = new NugetInspectorPackager(gson, externalIdFactory);
final NugetParseResult result = packager.createDetectCodeLocation(dependencyNodeFile);
for (final DetectCodeLocation codeLocation : result.codeLocations) {
final BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
final BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
final DependencyGraphTransformer dependencyNodeTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
final BdioExternalIdentifier projectId = bdioPropertyHelper.createExternalIdentifier(codeLocation.getExternalId());
final BdioProject project = bdioNodeFactory.createProject(result.projectName, result.projectVersion, Forge.NUGET.toString(), projectId);
final Map<ExternalId, BdioNode> components = new HashMap<>();
components.put(codeLocation.getExternalId(), project);
final List<BdioComponent> bdioComponents = dependencyNodeTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), project, codeLocation.getDependencyGraph().getRootDependencies(), components);
assertEquals(bdioComponents.size(), bdioComponents.size());
}
}
Aggregations