fix: use PackageURL to canonicalize purls when matching deps.dev license response to SBOM purls#414
Conversation
Review Summary by QodoFix purl qualifier mismatch in license response normalization
WalkthroughsDescription• Strip purl qualifiers when matching deps.dev responses to SBOM purls • Fix incompatibleDependencies always being empty due to qualifier mismatch • Store qualifier-free purls as map keys for consistent lookups • Add three comprehensive tests for qualifier handling scenarios Diagramflowchart LR
A["Backend Response<br/>with ?scope=compile"] -- "Strip qualifiers" --> B["Normalized Purl<br/>Base"]
C["SBOM Purls<br/>without qualifiers"] -- "Strip qualifiers" --> B
B -- "Compare & Match" --> D["Map with<br/>Qualifier-free Keys"]
File Changes1. src/license/licenses_api.js
|
Code Review by Qodo
1. Quadratic purl matching
|
2cf4fa3 to
b26a6c1
Compare
|
/review |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
ruromero
left a comment
There was a problem hiding this comment.
I'd prefer to use the PackageURL to canonicalize the purls.
What if you define a function like this?
function getCorePurl(purl) {
const parsed = PackageURL.fromString(purl);
const corePurl = new PackageURL(
parsed.type,
parsed.namespace,
parsed.name,
parsed.version,
null, // no qualifiers
null // no subpath
);
return corePurl.toString();
}
b26a6c1 to
ef6b443
Compare
|
Thanks for the review. fix has been updated. |
ruromero
left a comment
There was a problem hiding this comment.
Thanks.
Let me know what you think about my comments
…nse response to SBOM purls The deps.dev backend returns package purls with qualifiers like ?scope=compile (e.g. pkg:maven/org.mariadb.jdbc/mariadb-java-client@3.1.4?scope=compile), while the SBOM generated by the client uses plain purls without qualifiers. The strict purls.includes(purl) check in normalizeLicensesResponse never matched qualifier-suffixed purls, causing incompatibleDependencies to always be empty even when LGPL/copyleft dependencies were present. Fix by using PackageURL.fromString() to parse purls and reconstructing them without qualifiers or subpath via new PackageURL(..., null, null). This produces canonical core purls for both the allowed set and the backend keys, making the match resilient to any qualifiers the backend may return. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ef6b443 to
7c7f9a9
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
added a second commit to remove unused |
fixes: #413