@pnpm/deps.compliance.sbom 1100.3.10 → 1100.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/lib/collectComponents.d.ts +1 -0
- package/lib/collectComponents.js +23 -4
- package/lib/getPkgMetadata.d.ts +3 -3
- package/lib/getPkgMetadata.js +4 -4
- package/lib/purl.d.ts +7 -0
- package/lib/purl.js +34 -0
- package/package.json +15 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @pnpm/deps.compliance.sbom
|
|
2
2
|
|
|
3
|
+
## 1100.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **Security fix.** Affects projects using `namedRegistries` on pnpm 11.1.0–11.19.x. It is **semi-breaking** for those projects — see "If you use named registries" below.
|
|
8
|
+
|
|
9
|
+
The lockfile recorded no marker for which registry a package came from. Packages were keyed by `name@version` alone, and entry lookup went through `refToRelative(ref, name)`, so a dependency you declared against one registry could be satisfied by an entry that was actually resolved from another. When two registries served the same name and version, both collapsed onto a single `packages:` entry and whichever resolved first decided the tarball every consumer got.
|
|
10
|
+
|
|
11
|
+
That is a package-substitution risk: a package you expect from your private registry could be installed from a different registry that publishes the same name and version, and the lockfile recorded nothing that would let you tell.
|
|
12
|
+
|
|
13
|
+
Packages resolved from a named registry are now recorded under registry-qualified keys (`<name>@<registryName>:<version>`, e.g. `foo@work:1.0.0`), so each registry gets its own entry and the lockfile pins which one a dependency came from.
|
|
14
|
+
|
|
15
|
+
The lockfile format version is unchanged. Registry-qualified keys appear only for packages resolved from a named registry, so a project that does not use `namedRegistries` sees no difference, and older pnpm versions keep reading the file.
|
|
16
|
+
|
|
17
|
+
### If you use named registries
|
|
18
|
+
|
|
19
|
+
Your next non-frozen install re-keys those entries, which shows up as a lockfile diff. Commit it — that diff is the fix being applied. Review it: an entry that moves to a registry you did not expect is worth investigating.
|
|
20
|
+
|
|
21
|
+
Everyone working on the project should be on this version or newer before you do. An older pnpm reads the re-keyed lockfile fine — frozen installs are unaffected — but it does not produce registry-qualified keys itself, so any install that updates the lockfile writes those entries back to the old shape, and the next install on a current pnpm re-qualifies them. The result is a lockfile that flips back and forth, and while it is in the old shape the project is exposed again. Because the lockfile format version is deliberately unchanged, pnpm cannot detect this and warn you about it.
|
|
22
|
+
|
|
23
|
+
There is no setting to keep the old behavior: the old shape is the vulnerability.
|
|
24
|
+
|
|
25
|
+
Tarball URLs that follow the standard registry layout are no longer written to the lockfile for named-registry packages; they are recomputed from the `namedRegistries` setting on demand.
|
|
26
|
+
|
|
27
|
+
To use named registries, map your aliases in `pnpm-workspace.yaml`:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
namedRegistries:
|
|
31
|
+
work: https://npm.enterprise.example.com/
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### New built-in `npmjs:` alias
|
|
35
|
+
|
|
36
|
+
`npmjs:` now resolves to `https://registry.npmjs.org/` with no configuration, alongside the existing `gh:` alias for GitHub Packages. It pins a dependency to the public registry even when `registry` points elsewhere, such as an internal proxy:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{ "dependencies": { "left-pad": "npmjs:^1.3.0" } }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`npm:` cannot do this — it is the alias protocol (`npm:<name>@<range>`) and resolves through whatever `registry` points at.
|
|
43
|
+
|
|
44
|
+
**If you mirror or proxy npmjs, point the alias at your mirror:**
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
namedRegistries:
|
|
48
|
+
npmjs: https://npm.internal.example.com/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Built-in registry URLs are also the prefixes a lockfile's recorded tarball URL is matched against when pnpm verifies a package. Without the override, an entry whose tarball URL is on `registry.npmjs.org` is verified against the public registry rather than your mirror. This only affects lockfiles that record such URLs — a canonical URL for your configured registry is omitted from the lockfile and unaffected — and only when a tarball-URL, `minimumReleaseAge`, or `trustPolicy` check runs. Overriding the alias is the same escape hatch GHES users already have for `gh`.
|
|
52
|
+
|
|
53
|
+
Every alias the lockfile references must stay in `namedRegistries`: reading an entry whose alias is gone fails with `ERR_PNPM_MISSING_NAMED_REGISTRY` rather than silently falling back to the default registry, since that would fetch a different package. Renaming an alias re-resolves the packages that used it.
|
|
54
|
+
|
|
55
|
+
Named registry aliases that shadow a reserved dependency specifier prefix (`file`, `link`, `workspace`, `runtime`, `npm`, `jsr`, ...) are now rejected with `ERR_PNPM_RESERVED_NAMED_REGISTRY_NAME` instead of being silently shadowed by the corresponding resolver.
|
|
56
|
+
|
|
57
|
+
`pnpm licenses` and `pnpm sbom` now keep the two artifacts apart as well: license records carry the registry alias, and SBOM components carry the purl `repository_url` qualifier.
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Fixed the order in which pnpm matches a lockfile's recorded tarball URL against known registry URLs. Two registry URLs of equal length were previously ordered arbitrarily, so which one a tarball URL matched could differ between runs.
|
|
62
|
+
|
|
63
|
+
- Updated dependencies:
|
|
64
|
+
- @pnpm/config.normalize-registries@1100.1.0
|
|
65
|
+
- @pnpm/constants@1101.0.0
|
|
66
|
+
- @pnpm/error@1100.1.1
|
|
67
|
+
- @pnpm/lockfile.detect-dep-types@1100.0.19
|
|
68
|
+
- @pnpm/lockfile.types@1100.0.19
|
|
69
|
+
- @pnpm/lockfile.utils@1101.0.0
|
|
70
|
+
- @pnpm/lockfile.walker@1100.0.19
|
|
71
|
+
- @pnpm/pkg-manifest.reader@1100.0.15
|
|
72
|
+
- @pnpm/resolving.resolver-base@1101.1.0
|
|
73
|
+
- @pnpm/store.index@1100.2.3
|
|
74
|
+
- @pnpm/store.pkg-finder@1100.0.28
|
|
75
|
+
- @pnpm/types@1101.9.0
|
|
76
|
+
|
|
3
77
|
## 1100.3.10
|
|
4
78
|
|
|
5
79
|
### Patch Changes
|
|
@@ -24,6 +24,7 @@ export interface CollectSbomComponentsOptions {
|
|
|
24
24
|
[dependenciesField in DependenciesField]: boolean;
|
|
25
25
|
};
|
|
26
26
|
registries: Registries;
|
|
27
|
+
namedRegistries?: Record<string, string>;
|
|
27
28
|
lockfileDir: string;
|
|
28
29
|
includedImporterIds?: ProjectId[];
|
|
29
30
|
lockfileOnly?: boolean;
|
package/lib/collectComponents.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { normalizeNamedRegistries } from '@pnpm/config.normalize-registries';
|
|
3
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
4
|
import { DepType, detectDepTypes } from '@pnpm/lockfile.detect-dep-types';
|
|
3
5
|
import { nameVerFromPkgSnapshot, pkgSnapshotToResolution } from '@pnpm/lockfile.utils';
|
|
4
6
|
import { lockfileWalkerGroupImporterSteps, } from '@pnpm/lockfile.walker';
|
|
@@ -127,19 +129,36 @@ export async function collectSbomComponents(opts) {
|
|
|
127
129
|
async function walkStep(step, parentPurl, depTypes, componentsMap, relationships, opts, metadataOpts) {
|
|
128
130
|
await Promise.all(step.dependencies.map(async (dep) => {
|
|
129
131
|
const { depPath, pkgSnapshot, next } = dep;
|
|
130
|
-
const { name, version, nonSemverVersion } = nameVerFromPkgSnapshot(depPath, pkgSnapshot);
|
|
132
|
+
const { name, version, nonSemverVersion, registryName } = nameVerFromPkgSnapshot(depPath, pkgSnapshot);
|
|
131
133
|
if (!name || !version)
|
|
132
134
|
return;
|
|
133
|
-
|
|
135
|
+
// Resolve the alias before the purl is built. An unknown alias would
|
|
136
|
+
// otherwise yield an unqualified purl that collides with the same
|
|
137
|
+
// package from the default registry, and the `componentsMap.has(purl)`
|
|
138
|
+
// shortcut below would drop this component before
|
|
139
|
+
// `pkgSnapshotToResolution` ever got to reject it — silently omitting an
|
|
140
|
+
// artifact from a compliance document.
|
|
141
|
+
const registryUrl = registryName == null
|
|
142
|
+
? undefined
|
|
143
|
+
: normalizeNamedRegistries(opts.namedRegistries)[registryName];
|
|
144
|
+
if (registryName != null && registryUrl == null) {
|
|
145
|
+
throw new PnpmError('MISSING_NAMED_REGISTRY', `Cannot describe package "${depPath}": it was resolved from the named registry '${registryName}:', which is not present in the namedRegistries setting.`, { hint: `Add '${registryName}' to the namedRegistries setting in pnpm-workspace.yaml.` });
|
|
146
|
+
}
|
|
147
|
+
const purl = buildPurl({
|
|
148
|
+
name,
|
|
149
|
+
version,
|
|
150
|
+
nonSemverVersion: nonSemverVersion ?? undefined,
|
|
151
|
+
registryUrl,
|
|
152
|
+
});
|
|
134
153
|
relationships.push({ from: parentPurl, to: purl });
|
|
135
154
|
if (componentsMap.has(purl))
|
|
136
155
|
return;
|
|
137
156
|
const integrity = pkgSnapshot.resolution.integrity;
|
|
138
|
-
const resolution = pkgSnapshotToResolution(depPath, pkgSnapshot, opts.registries);
|
|
157
|
+
const resolution = pkgSnapshotToResolution(depPath, pkgSnapshot, { registries: opts.registries, namedRegistries: opts.namedRegistries });
|
|
139
158
|
const tarballUrl = resolution.tarball ?? gitDownloadUrl(resolution);
|
|
140
159
|
let metadata = {};
|
|
141
160
|
if (metadataOpts) {
|
|
142
|
-
metadata = await getPkgMetadata(depPath, pkgSnapshot, opts.registries, metadataOpts);
|
|
161
|
+
metadata = await getPkgMetadata(depPath, pkgSnapshot, { registries: opts.registries, namedRegistries: opts.namedRegistries }, metadataOpts);
|
|
143
162
|
}
|
|
144
163
|
const component = {
|
|
145
164
|
name,
|
package/lib/getPkgMetadata.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type PackageSnapshot } from '@pnpm/lockfile.utils';
|
|
1
|
+
import { type PackageSnapshot, type PkgSnapshotToResolutionOptions } from '@pnpm/lockfile.utils';
|
|
2
2
|
import type { StoreIndex } from '@pnpm/store.index';
|
|
3
|
-
import type { DepPath
|
|
3
|
+
import type { DepPath } from '@pnpm/types';
|
|
4
4
|
export interface PkgMetadata {
|
|
5
5
|
license?: string;
|
|
6
6
|
description?: string;
|
|
@@ -15,5 +15,5 @@ export interface GetPkgMetadataOptions {
|
|
|
15
15
|
lockfileDir: string;
|
|
16
16
|
virtualStoreDirMaxLength: number;
|
|
17
17
|
}
|
|
18
|
-
export declare function getPkgMetadata(depPath: DepPath, snapshot: PackageSnapshot,
|
|
18
|
+
export declare function getPkgMetadata(depPath: DepPath, snapshot: PackageSnapshot, registryOpts: PkgSnapshotToResolutionOptions, opts: GetPkgMetadataOptions): Promise<PkgMetadata>;
|
|
19
19
|
export declare function bugsUrlFromField(field: unknown): string | undefined;
|
package/lib/getPkgMetadata.js
CHANGED
|
@@ -4,12 +4,12 @@ import { readPackageJson } from '@pnpm/pkg-manifest.reader';
|
|
|
4
4
|
import { readPackageFileMap } from '@pnpm/store.pkg-finder';
|
|
5
5
|
import pLimit from 'p-limit';
|
|
6
6
|
const limitMetadataReads = pLimit(4);
|
|
7
|
-
export async function getPkgMetadata(depPath, snapshot,
|
|
8
|
-
return limitMetadataReads(() => getPkgMetadataUnclamped(depPath, snapshot,
|
|
7
|
+
export async function getPkgMetadata(depPath, snapshot, registryOpts, opts) {
|
|
8
|
+
return limitMetadataReads(() => getPkgMetadataUnclamped(depPath, snapshot, registryOpts, opts));
|
|
9
9
|
}
|
|
10
|
-
async function getPkgMetadataUnclamped(depPath, snapshot,
|
|
10
|
+
async function getPkgMetadataUnclamped(depPath, snapshot, registryOpts, opts) {
|
|
11
11
|
const id = packageIdFromSnapshot(depPath, snapshot);
|
|
12
|
-
const resolution = pkgSnapshotToResolution(depPath, snapshot,
|
|
12
|
+
const resolution = pkgSnapshotToResolution(depPath, snapshot, registryOpts);
|
|
13
13
|
let files;
|
|
14
14
|
try {
|
|
15
15
|
const result = await readPackageFileMap(resolution, id, opts);
|
package/lib/purl.d.ts
CHANGED
|
@@ -11,4 +11,11 @@ export declare function buildPurl(opts: {
|
|
|
11
11
|
name: string;
|
|
12
12
|
version: string;
|
|
13
13
|
nonSemverVersion?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Registry the package was resolved from, when it is not the default
|
|
16
|
+
* one. Emitted as the spec's `repository_url` qualifier, which is what
|
|
17
|
+
* keeps the same name and version served by two registries from
|
|
18
|
+
* collapsing onto one component.
|
|
19
|
+
*/
|
|
20
|
+
registryUrl?: string;
|
|
14
21
|
}): string;
|
package/lib/purl.js
CHANGED
|
@@ -18,6 +18,40 @@ export function buildPurl(opts) {
|
|
|
18
18
|
const encodedUrl = encodeURIComponent(opts.nonSemverVersion);
|
|
19
19
|
return `pkg:npm/${encodePurlName(opts.name)}@${encodeURIComponent(opts.version)}?vcs_url=${encodedUrl}`;
|
|
20
20
|
}
|
|
21
|
+
if (opts.registryUrl) {
|
|
22
|
+
const repositoryUrl = sanitizeRegistryUrl(opts.registryUrl);
|
|
23
|
+
return `pkg:npm/${encodePurlName(opts.name)}@${opts.version}?repository_url=${encodeURIComponent(repositoryUrl)}`;
|
|
24
|
+
}
|
|
21
25
|
return `pkg:npm/${encodePurlName(opts.name)}@${opts.version}`;
|
|
22
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Reduce a registry URL to the parts that identify the registry, dropping
|
|
29
|
+
* anything that could carry a secret.
|
|
30
|
+
*
|
|
31
|
+
* An SBOM is meant to be published, and a `namedRegistries` entry may
|
|
32
|
+
* legitimately embed credentials — as userinfo
|
|
33
|
+
* (`https://user:token@npm.example.com/`) or in a query string
|
|
34
|
+
* (`?api_key=…`). Origin and path are kept because two registries can
|
|
35
|
+
* differ only by path (`https://npm.example.com/team-a/` vs `/team-b/`),
|
|
36
|
+
* so trimming to the origin would recreate the very collision this
|
|
37
|
+
* qualifier exists to prevent.
|
|
38
|
+
*
|
|
39
|
+
* A URL that doesn't parse is returned unchanged: it has no userinfo to
|
|
40
|
+
* strip, and `namedRegistries` values are validated as http(s) URLs when
|
|
41
|
+
* the resolver is constructed, so this is unreachable in practice.
|
|
42
|
+
*/
|
|
43
|
+
function sanitizeRegistryUrl(url) {
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = new URL(url);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return url;
|
|
50
|
+
}
|
|
51
|
+
parsed.username = '';
|
|
52
|
+
parsed.password = '';
|
|
53
|
+
parsed.search = '';
|
|
54
|
+
parsed.hash = '';
|
|
55
|
+
return parsed.toString();
|
|
56
|
+
}
|
|
23
57
|
//# sourceMappingURL=purl.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/deps.compliance.sbom",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.4.0",
|
|
4
4
|
"description": "Generate SBOM from pnpm lockfile",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -31,16 +31,19 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@cyclonedx/cyclonedx-library": "10.1.0",
|
|
34
|
+
"@pnpm/config.normalize-registries": "1100.1.0",
|
|
35
|
+
"@pnpm/constants": "1101.0.0",
|
|
34
36
|
"@pnpm/deps.compliance.license-resolver": "1100.0.1",
|
|
35
|
-
"@pnpm/
|
|
36
|
-
"@pnpm/lockfile.types": "1100.0.
|
|
37
|
-
"@pnpm/lockfile.
|
|
38
|
-
"@pnpm/lockfile.
|
|
39
|
-
"@pnpm/
|
|
40
|
-
"@pnpm/
|
|
41
|
-
"@pnpm/
|
|
42
|
-
"@pnpm/store.
|
|
43
|
-
"@pnpm/
|
|
37
|
+
"@pnpm/error": "1100.1.1",
|
|
38
|
+
"@pnpm/lockfile.detect-dep-types": "1100.0.19",
|
|
39
|
+
"@pnpm/lockfile.types": "1100.0.19",
|
|
40
|
+
"@pnpm/lockfile.utils": "1101.0.0",
|
|
41
|
+
"@pnpm/lockfile.walker": "1100.0.19",
|
|
42
|
+
"@pnpm/pkg-manifest.reader": "1100.0.15",
|
|
43
|
+
"@pnpm/resolving.resolver-base": "1101.1.0",
|
|
44
|
+
"@pnpm/store.index": "1100.2.3",
|
|
45
|
+
"@pnpm/store.pkg-finder": "1100.0.28",
|
|
46
|
+
"@pnpm/types": "1101.9.0",
|
|
44
47
|
"p-limit": "^7.3.1",
|
|
45
48
|
"ssri": "13.0.1"
|
|
46
49
|
},
|
|
@@ -49,9 +52,9 @@
|
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@jest/globals": "30.4.1",
|
|
52
|
-
"@pnpm/deps.compliance.sbom": "1100.
|
|
55
|
+
"@pnpm/deps.compliance.sbom": "1100.4.0",
|
|
53
56
|
"@pnpm/logger": "1100.0.0",
|
|
54
|
-
"@pnpm/store.cafs": "1100.1.
|
|
57
|
+
"@pnpm/store.cafs": "1100.1.18",
|
|
55
58
|
"@types/ssri": "^7.1.5"
|
|
56
59
|
},
|
|
57
60
|
"engines": {
|