Skip to content

Commit fbb031d

Browse files
authored
Add info about verifying npm modules (#3272)
[ ] Check if this is a typo or other quick fix and ignore the rest :) ## Type of change Update to JavaScript verification content ### What should this PR do? Explain how chainctl libraries verify works for JavaScript packages ### Why are we making this change? New chainctl functionality: https://github.com/chainguard-dev/mono/pull/37476/changes ### What are the acceptance criteria? Content should be clear and accurate, and appear in the correct location ### How should this PR be tested? Review the deploy preview --------- Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
1 parent b5c04d1 commit fbb031d

1 file changed

Lines changed: 70 additions & 2 deletions

File tree

content/chainguard/libraries/verification.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,16 @@ chainctl libraries verify ~/.m2/repository/net/logstash/logback/logstash-logback
211211
To integrate this into your build pipeline, add the verification step after
212212
dependency resolution and before the packaging phase.
213213

214-
### Analyze an npm tarball
214+
### Analyze JavaScript packages
215+
216+
`chainctl libraries verify` can scan local package manager caches and stores
217+
to confirm that your installed JavaScript packages were built by Chainguard. It supports the following JavaScript package managers:
218+
219+
- pnpm store: auto-detected by `v10/index/` or `v11/index/` structure (pnpm v10 and v11 supported)
220+
- npm cache: auto-detected by `_cacache/index-v5/` structure
221+
- Yarn Classic: v1.x, requires `yarn:` prefix
222+
223+
#### Analyze an npm tarball
215224

216225
Verify an npm package tarball to confirm it was built by Chainguard:
217226

@@ -224,7 +233,66 @@ and `9.0.0`)
224233

225234
Verification uses SLSA provenance attestations. `chainctl` computes a SHA-512 digest of the tarball locally, fetches the signed attestation bundle, and uses `cosign` to confirm that the signature is valid, the certificate chains to the Sigstore root, the signer identity matches the Chainguard JavaScript builder, and the digest matches what was attested at build time.
226235

227-
Verification currently operates on individual npm tarballs.
236+
#### Verify an npm cache
237+
238+
Verify your npm cache:
239+
240+
```sh
241+
chainctl libraries verify "$(npm config get cache)"
242+
```
243+
244+
#### Verify a pnpm store
245+
246+
Verify your pnpm store:
247+
248+
```sh
249+
chainctl libraries verify "$(pnpm store path)"
250+
```
251+
252+
pnpm v9 and earlier are not supported. Verification works by comparing
253+
the tarball hash recorded in your local store against the hash in Chainguard's
254+
signed SLSA attestation. pnpm v10 records this hash in the index file path;
255+
pnpm v9 does not.
256+
257+
#### Verify a Yarn Classic cache
258+
259+
Verify a Yarn Classic (v1) cache:
260+
261+
```sh
262+
chainctl libraries verify yarn:
263+
```
264+
265+
To specify a non-default cache location:
266+
267+
```sh
268+
chainctl libraries verify yarn:~/Library/Caches/Yarn/v6
269+
```
270+
271+
Unlike npm and pnpm, Yarn Classic requires the `yarn:` prefix because its
272+
cache directory layout cannot be reliably auto-detected.
273+
274+
275+
#### Verify a `node_modules` directory
276+
277+
Verify npm packages installed in a `node_modules` directory:
278+
279+
```sh
280+
chainctl libraries verify ./node_modules
281+
```
282+
283+
If `.package-lock.json` is not present, the directory is not recognized as an npm tree and verification will not run.
284+
285+
#### Verify a container image
286+
287+
Verify JavaScript packages inside a container image:
288+
289+
```sh
290+
chainctl libraries verify IMAGE:TAG
291+
```
292+
293+
Coverage is reported as the percentage of JavaScript packages in the image that are confirmed Chainguard-rebuilt libraries.
294+
295+
Images built with npm versions earlier than v7, or where `.package-lock.json` was removed during the build, cannot be verified this way.
228296

229297
### Other bundled artifact formats
230298

0 commit comments

Comments
 (0)