use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class NugetInspectorParser method createDetectCodeLocationFromNugetContainer.
private Optional<NugetParseResult> createDetectCodeLocationFromNugetContainer(NugetContainer nugetContainer) {
NugetParseResult parseResult;
String projectName = "";
String projectVersionName = "";
if (nugetContainer == null) {
return Optional.empty();
}
if (NugetContainerType.SOLUTION == nugetContainer.type) {
projectName = nugetContainer.name;
projectVersionName = nugetContainer.version;
List<CodeLocation> codeLocations = new ArrayList<>();
for (NugetContainer container : nugetContainer.children) {
if (container == null)
continue;
NugetDependencyNodeBuilder builder = new NugetDependencyNodeBuilder();
builder.addPackageSets(container.packages);
DependencyGraph children = builder.createDependencyGraph(container.dependencies);
if (StringUtils.isBlank(projectVersionName)) {
projectVersionName = container.version;
}
CodeLocation codeLocation = new CodeLocation(children, externalIdFactory.createNameVersionExternalId(Forge.NUGET, projectName, projectVersionName), convertSourcePath(container.sourcePath));
codeLocations.add(codeLocation);
}
parseResult = new NugetParseResult(projectName, projectVersionName, codeLocations);
} else if (NugetContainerType.PROJECT == nugetContainer.type) {
projectName = nugetContainer.name;
projectVersionName = nugetContainer.version;
NugetDependencyNodeBuilder builder = new NugetDependencyNodeBuilder();
builder.addPackageSets(nugetContainer.packages);
DependencyGraph children = builder.createDependencyGraph(nugetContainer.dependencies);
CodeLocation codeLocation = new CodeLocation(children, externalIdFactory.createNameVersionExternalId(Forge.NUGET, projectName, projectVersionName), convertSourcePath(nugetContainer.sourcePath));
parseResult = new NugetParseResult(projectName, projectVersionName, codeLocation);
} else {
parseResult = null;
}
return Optional.ofNullable(parseResult);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class NugetInspectorParser method createCodeLocation.
public NugetParseResult createCodeLocation(String dependencyFileText) {
NugetInspection nugetInspection = gson.fromJson(dependencyFileText, NugetInspection.class);
List<CodeLocation> codeLocations = new ArrayList<>();
String projectName = "";
String projectVersion = "";
for (NugetContainer it : nugetInspection.containers) {
Optional<NugetParseResult> possibleParseResult = createDetectCodeLocationFromNugetContainer(it);
if (possibleParseResult.isPresent()) {
NugetParseResult result = possibleParseResult.get();
if (StringUtils.isNotBlank(result.getProjectName())) {
projectName = result.getProjectName();
projectVersion = result.getProjectVersion();
}
codeLocations.addAll(result.getCodeLocations());
}
}
return new NugetParseResult(projectName, projectVersion, codeLocations);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PnpmLockYamlParser method createCodeLocationsFromImports.
private List<CodeLocation> createCodeLocationsFromImports(File sourcePath, PnpmLockYaml pnpmLockYaml, PnpmLinkedPackageResolver linkedPackageResolver, @Nullable NameVersion projectNameVersion) throws IntegrationException {
if (MapUtils.isEmpty(pnpmLockYaml.importers)) {
return Collections.emptyList();
}
List<CodeLocation> codeLocations = new LinkedList<>();
for (Map.Entry<String, PnpmProjectPackage> projectPackageInfo : pnpmLockYaml.importers.entrySet()) {
String projectKey = projectPackageInfo.getKey();
PnpmProjectPackage projectPackage = projectPackageInfo.getValue();
NameVersion extractedNameVersion = extractProjectInfo(projectPackageInfo, linkedPackageResolver, projectNameVersion);
String reportingProjectPackagePath = null;
if (!isNodeRoot.evaluate(projectKey)) {
reportingProjectPackagePath = projectKey;
}
File generatedSourcePath = generateCodeLocationSourcePath(sourcePath, reportingProjectPackagePath);
codeLocations.add(pnpmTransformer.generateCodeLocation(generatedSourcePath, projectPackage, reportingProjectPackagePath, extractedNameVersion, pnpmLockYaml.packages, linkedPackageResolver));
}
return codeLocations;
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PnpmYamlTransformer method generateCodeLocation.
public CodeLocation generateCodeLocation(File sourcePath, PnpmProjectPackage projectPackage, @Nullable String reportingProjectPackagePath, @Nullable NameVersion projectNameVersion, @Nullable Map<String, PnpmPackageInfo> packageMap, PnpmLinkedPackageResolver linkedPackageResolver) throws IntegrationException {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
List<String> rootPackageIds = extractRootPackageIds(projectPackage, reportingProjectPackagePath, linkedPackageResolver);
buildGraph(dependencyGraph, rootPackageIds, packageMap, linkedPackageResolver, reportingProjectPackagePath);
if (projectNameVersion != null) {
return new CodeLocation(dependencyGraph, ExternalId.FACTORY.createNameVersionExternalId(Forge.NPMJS, projectNameVersion.getName(), projectNameVersion.getVersion()), sourcePath);
}
return new CodeLocation(dependencyGraph, sourcePath);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PoetryExtractor method extract.
public Extraction extract(File poetryLock, @Nullable TomlTable toolDotPoetrySection) {
try {
DependencyGraph graph = poetryLockParser.parseLockFile(FileUtils.readFileToString(poetryLock, StandardCharsets.UTF_8));
CodeLocation codeLocation = new CodeLocation(graph);
Optional<NameVersion> poetryNameVersion = extractNameVersionFromToolDotPoetrySection(toolDotPoetrySection);
if (poetryNameVersion.isPresent()) {
return new Extraction.Builder().success(codeLocation).projectName(poetryNameVersion.get().getName()).projectVersion(poetryNameVersion.get().getVersion()).build();
}
return new Extraction.Builder().success(codeLocation).build();
} catch (IOException e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations