Skip to content

Commit 5508e4e

Browse files
authored
Merge pull request #1382 from blackducksoftware/dev/dterry/IDETECT-4642-pnpm-missing-packages
pnpm missing packages
2 parents 50a56ed + dc70058 commit 5508e4e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmYamlTransformer.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ private List<String> extractRootPackageIds(
193193

194194
private String convertRawEntryToPackageId(String name, String version, PnpmLinkedPackageResolver linkedPackageResolver, @Nullable String reportingProjectPackagePath) {
195195
name = StringUtils.strip(name, "'");
196+
196197
if (version.startsWith(LINKED_PACKAGE_PREFIX)) {
197198
// a linked project package's version will be referenced in the format: <linkPrefix><pathToLinkedPackageRelativeToReportingProjectPackage>
198199
version = linkedPackageResolver.resolveVersionOfLinkedPackage(reportingProjectPackagePath, version.replace(LINKED_PACKAGE_PREFIX, ""));
@@ -205,16 +206,15 @@ private String convertRawEntryToPackageId(String name, String version, PnpmLinke
205206
packageFormat = "/%s@%s";
206207
}
207208

209+
version = removeExtraVersionInformation(version);
210+
208211
return String.format(packageFormat, name, version);
209212
}
210213

211214
private Optional<NameVersion> parseNameVersionFromId(String id) {
212215
// ids follow format: /name@version in v6, name@version in v9
213216
try {
214-
// It seems critical not to send this extra information in () or the kb will fail matching it.
215-
if (id.contains("(")) {
216-
id = id.split("\\(")[0];
217-
}
217+
id = removeExtraVersionInformation(id);
218218

219219
int indexOfLastSlash = id.lastIndexOf("@");
220220
// v9 lockfile does not have names starting with /, v 6 does
@@ -273,4 +273,13 @@ private boolean isRootPackage(String id, List<String> rootIds) {
273273
.anyMatch(id::equals); // for file dependencies, they are declared as <name> : <fileIdAsReportedInPackagesSection>
274274
}
275275

276+
private String removeExtraVersionInformation(String version) {
277+
// Need to remove extra information from version or we will not appropriately
278+
// perform KB matches later.
279+
if (version != null && version.contains("(")) {
280+
version = version.split("\\(")[0];
281+
}
282+
283+
return version;
284+
}
276285
}

documentation/src/main/markdown/currentreleasenotes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
### Resolved issues
2828

29-
*
29+
* (IDETECT-4642) - Improved handling of pnpm packages that contain detailed version information in the pnpm-lock.yaml. Resolving [detect_product_short] missing some packages through failure to link direct and transitive dependencies.
3030

3131
### Dependency updates
3232

0 commit comments

Comments
 (0)