Skip to content

Commit d87ebea

Browse files
chore(deps): bump packageurl-js from 1.2.1 to 2.0.1 (#1142)
Bumps [packageurl-js](https://github.com/package-url/packageurl-js) from 1.2.1 to 2.0.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/package-url/packageurl-js/blob/master/CHANGELOG.md">packageurl-js's changelog</a>.</em></p> <blockquote> <h1>2.0.1</h1> <h2>Bug Fix</h2> <ul> <li>Fix decoding problems around the <code>%</code> character <a href="https://redirect.github.com/package-url/packageurl-js/issues/75">#75</a> (fix contributed by <a href="https://github.com/jdalton"><code>@​jdalton</code></a>)</li> </ul> <h1>2.0.0</h1> <ul> <li>Significant refactor based on code from <a href="https://github.com/jdalton"><code>@​jdalton</code></a></li> <li>Numerous bug fixes and improvements the community was asking for <ul> <li>See closed issues and PRs for details (too many to list here)</li> </ul> </li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/package-url/packageurl-js/commit/cd1eb4b050ea66462a729f800166ee0b02fc4c5c"><code>cd1eb4b</code></a> chore: bump to v2.0.1 (<a href="https://redirect.github.com/package-url/packageurl-js/issues/77">#77</a>)</li> <li><a href="https://github.com/package-url/packageurl-js/commit/f7dccd6dcb82a5a7c898b0e9408f88444be7b6db"><code>f7dccd6</code></a> fix: error on decode with meaningful message</li> <li><a href="https://github.com/package-url/packageurl-js/commit/07b818b64ba4fb1baf74a2ffd1219e1121028730"><code>07b818b</code></a> fix: only decode in parseString</li> <li><a href="https://github.com/package-url/packageurl-js/commit/c2f576f4b6b31590656538e26c97a018190de640"><code>c2f576f</code></a> bump to v2.0.0 (<a href="https://redirect.github.com/package-url/packageurl-js/issues/74">#74</a>)</li> <li><a href="https://github.com/package-url/packageurl-js/commit/b5660a513295ad99f21cc8e98c4e20a27d4f374b"><code>b5660a5</code></a> Merge pull request <a href="https://redirect.github.com/package-url/packageurl-js/issues/73">#73</a> from package-url/jdalton/sync</li> <li><a href="https://github.com/package-url/packageurl-js/commit/400de0cb8ecffcd540f18269b6b2176f4d9a08bd"><code>400de0c</code></a> Merge pull request <a href="https://redirect.github.com/package-url/packageurl-js/issues/72">#72</a> from package-url/dependabot/npm_and_yarn/braces-3.0.3</li> <li><a href="https://github.com/package-url/packageurl-js/commit/b6c8ce8abe592f327154b5733cd9aad350337cc3"><code>b6c8ce8</code></a> fix: correct package-url.d.ts readonly type casing</li> <li><a href="https://github.com/package-url/packageurl-js/commit/96822afa27a446be58efad27bcf21f6c27585397"><code>96822af</code></a> fix: correct param name typos</li> <li><a href="https://github.com/package-url/packageurl-js/commit/f81a6be5ef1ffd74ca0a3fc73a684beaec7e5c63"><code>f81a6be</code></a> fix: use encodeQualifierValue for qualifierKey and qualifierValue</li> <li><a href="https://github.com/package-url/packageurl-js/commit/ff590d20a64a89152d4bb2cae3ee32a30bb28755"><code>ff590d2</code></a> feat: encode qualifiers with URLSearchParams</li> <li>Additional commits viewable in <a href="https://github.com/package-url/packageurl-js/compare/v1.2.1...v2.0.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=packageurl-js&package-manager=npm_and_yarn&previous-version=1.2.1&new-version=2.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> > **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Jan Kowalleck <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jan Kowalleck <[email protected]>
1 parent fba061a commit d87ebea

File tree

8 files changed

+27
-52
lines changed

8 files changed

+27
-52
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ jobs:
391391
js-type: [ 'cjs', 'mjs' ]
392392
include:
393393
- # lowest reasonable number that works
394-
typescript-version: '^3.8'
394+
typescript-version: '^4.0'
395395
nodeTypes-version: '^14'
396396
js-type: 'cjs'
397397
env:

HISTORY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ All notable changes to this project will be documented in this file.
1818
* Serializers and `Bom`-Normalizers will take changed `Models.Bom.tools` into account ([#1152] via [#1163])
1919
* Dependencies
2020
* Support `libxmljs2@^0.35` (via [#1173])
21+
* Use `packageurl-js@^2.0.1`, was `@>=0.0.6 <0.0.8 || ^1` (via [#1142])
2122

23+
[#1142]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1142
2224
[#1152]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1152
2325
[#1163]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1163
2426
[#1173]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1173

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"node": ">=14.0.0"
8181
},
8282
"dependencies": {
83-
"packageurl-js": ">=0.0.6 <0.0.8 || ^1",
83+
"packageurl-js": "^2.0.1",
8484
"spdx-expression-parse": "^3.0.1 || ^4"
8585
},
8686
"optionalDependencies": {

src/_helpers/packageUrl.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/factories/fromNodePackageJson.node.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2727
*/
2828

2929
import type { PackageURL } from 'packageurl-js'
30+
import { PurlQualifierNames } from 'packageurl-js'
3031

3132
import {tryCanonicalizeGitUrl} from "../_helpers/gitUrl"
3233
import { isNotUndefined } from '../_helpers/notUndefined'
3334
import type { PackageJson } from '../_helpers/packageJson'
34-
import { PackageUrlQualifierNames } from '../_helpers/packageUrl'
3535
import { ExternalReferenceType } from '../enums/externalReferenceType'
3636
import type { Component } from '../models/component'
3737
import { ExternalReference } from '../models/externalReference'
@@ -137,20 +137,24 @@ export class PackageUrlFactory extends PlainPackageUrlFactory<'npm'> {
137137
#finalizeQualifiers (purl: PackageURL): PackageURL {
138138
const qualifiers = new Map(Object.entries(purl.qualifiers ?? {}))
139139

140-
const downloadUrl = qualifiers.get(PackageUrlQualifierNames.DownloadURL)
140+
const downloadUrl = qualifiers.get(PurlQualifierNames.DownloadUrl)
141141
if (downloadUrl !== undefined) {
142-
qualifiers.delete(PackageUrlQualifierNames.VcsUrl)
142+
qualifiers.delete(PurlQualifierNames.VcsUrl)
143143
if (npmDefaultRepositoryMatcher.test(downloadUrl)) {
144-
qualifiers.delete(PackageUrlQualifierNames.DownloadURL)
144+
qualifiers.delete(PurlQualifierNames.DownloadUrl)
145145
}
146146
}
147-
if (!qualifiers.has(PackageUrlQualifierNames.DownloadURL) && !qualifiers.has(PackageUrlQualifierNames.VcsUrl)) {
147+
if (!qualifiers.has(PurlQualifierNames.DownloadUrl) && !qualifiers.has(PurlQualifierNames.VcsUrl)) {
148148
// nothing to base a checksum on
149-
qualifiers.delete(PackageUrlQualifierNames.Checksum)
149+
qualifiers.delete(PurlQualifierNames.Checksum)
150+
}
151+
if (qualifiers.size > 0) {
152+
purl.qualifiers = Object.fromEntries(qualifiers.entries())
153+
/* @ts-expect-error TS2322 */
154+
purl.qualifiers.__proto__ = null /* eslint-disable-line no-proto -- intended */
155+
} else {
156+
purl.qualifiers = undefined
150157
}
151-
purl.qualifiers = qualifiers.size > 0
152-
? Object.fromEntries(qualifiers.entries())
153-
: undefined
154158

155159
return purl
156160
}

src/factories/packageUrl.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
import { PackageURL } from 'packageurl-js'
20+
import { PackageURL, PurlQualifierNames } from 'packageurl-js'
2121

22-
import { PackageUrlQualifierNames } from '../_helpers/packageUrl'
2322
import { ExternalReferenceType } from '../enums/externalReferenceType'
2423
import type { Component } from '../models/component'
2524

@@ -37,6 +36,8 @@ export class PackageUrlFactory<PurlType extends PackageURL['type'] = PackageURL[
3736
/* eslint-disable-next-line @typescript-eslint/no-inferrable-types -- docs */
3837
makeFromComponent (component: Component, sort: boolean = false): PackageURL | undefined {
3938
const qualifiers: PackageURL['qualifiers'] = {}
39+
/* @ts-expect-error TS2322 */
40+
qualifiers.__proto__ = null /* eslint-disable-line no-proto -- intended */
4041
let subpath: PackageURL['subpath'] = undefined
4142

4243
// sorting to allow reproducibility: use the last instance for a `extRef.type`, if multiples exist
@@ -55,17 +56,17 @@ export class PackageUrlFactory<PurlType extends PackageURL['type'] = PackageURL[
5556
/* eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- intended */
5657
switch (extRef.type) {
5758
case ExternalReferenceType.VCS:
58-
[qualifiers[PackageUrlQualifierNames.VcsUrl], subpath] = url.split('#', 2)
59+
[qualifiers[PurlQualifierNames.VcsUrl], subpath] = url.split('#', 2)
5960
break
6061
case ExternalReferenceType.Distribution:
61-
qualifiers[PackageUrlQualifierNames.DownloadURL] = url
62+
qualifiers[PurlQualifierNames.DownloadUrl] = url
6263
break
6364
}
6465
}
6566

6667
const hashes = component.hashes
6768
if (hashes.size > 0) {
68-
qualifiers[PackageUrlQualifierNames.Checksum] = Array.from(
69+
qualifiers[PurlQualifierNames.Checksum] = Array.from(
6970
sort
7071
? hashes.sorted()
7172
: hashes,

tests/integration/Factories.FromNodePackageJson.PackageUrlFactory.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ suite('integration: Factories.FromNodePackageJson.PackageUrlFactory', () => {
251251
vcs_url: 'git+https://foo.bar/repo.git'
252252
}, undefined)
253253
// expect objet's keys in alphabetical oder, expect sorted hash list
254-
const expectedString = 'pkg:testing/name?checksum=blake3%3Aaa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d%2Csha-256%3Ac3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2&vcs_url=git%2Bhttps%3A//foo.bar/repo.git'
254+
const expectedString = 'pkg:testing/name?checksum=blake3%3Aaa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d%2Csha-256%3Ac3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2&vcs_url=git%2Bhttps%3A%2F%2Ffoo.bar%2Frepo.git'
255255

256256
const actual = sut.makeFromComponent(component, true)
257257

@@ -287,7 +287,7 @@ suite('integration: Factories.FromNodePackageJson.PackageUrlFactory', () => {
287287
download_url: 'https://foo.bar/download-2'
288288
}, undefined)
289289
// expect objet's keys in alphabetical oder, expect sorted hash list
290-
const expectedString = 'pkg:testing/name?download_url=https%3A//foo.bar/download-2'
290+
const expectedString = 'pkg:testing/name?download_url=https%3A%2F%2Ffoo.bar%2Fdownload-2'
291291

292292
const actual1 = sut.makeFromComponent(component1, true)
293293
const actual2 = sut.makeFromComponent(component2, true)

tests/integration/Factories.PackageUrlFactory.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ suite('integration: Factories.PackageUrlFactory', () => {
174174
vcs_url: 'git+https://foo.bar/repo.git'
175175
}, undefined)
176176
// expect objet's keys in alphabetical oder, expect sorted hash list
177-
const expectedString = 'pkg:testing/name?checksum=blake3%3Aaa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d%2Csha-256%3Ac3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2&download_url=https%3A//foo.bar/download&vcs_url=git%2Bhttps%3A//foo.bar/repo.git'
177+
const expectedString = 'pkg:testing/name?checksum=blake3%3Aaa51dcd43d5c6c5203ee16906fd6b35db298b9b2e1de3fce81811d4806b76b7d%2Csha-256%3Ac3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2&download_url=https%3A%2F%2Ffoo.bar%2Fdownload&vcs_url=git%2Bhttps%3A%2F%2Ffoo.bar%2Frepo.git'
178178

179179
const actual = sut.makeFromComponent(component, true)
180180

@@ -213,7 +213,7 @@ suite('integration: Factories.PackageUrlFactory', () => {
213213
vcs_url: 'git+https://foo.bar/repo.git'
214214
}, undefined)
215215
// expect objet's keys in alphabetical oder, expect sorted hash list
216-
const expectedString = 'pkg:testing/name?download_url=https%3A//foo.bar/download-2&vcs_url=git%2Bhttps%3A//foo.bar/repo.git'
216+
const expectedString = 'pkg:testing/name?download_url=https%3A%2F%2Ffoo.bar%2Fdownload-2&vcs_url=git%2Bhttps%3A%2F%2Ffoo.bar%2Frepo.git'
217217

218218
const actual1 = sut.makeFromComponent(component1, true)
219219
const actual2 = sut.makeFromComponent(component2, true)

0 commit comments

Comments
 (0)