Skip to content

Commit f032e1c

Browse files
authored
feat: add npm audit signatures (#4827)
* feat: add npm audit signatures Implements [RFC: Improve signature verification](npm/rfcs#550) Adds a new sub-command to `audit`: `npm audit signatures` (following [`npm audit licenses`](#3452)) This command will verify registry signatures stored in the packument against a public key on the registry. Supporting: - Any registry that implements `host/-/npm/v1/keys` endpoint and provides `signatures` in the packument `dist` object - Validates public keys are not expired - Errors when encountering packages with missing signatures when the registry returns keys at `host/-/npm/v1/keys` - Errors when encountering invalid signatures - Output: json/human formats
1 parent ef8d2ed commit f032e1c

File tree

8 files changed

+2086
-13
lines changed

8 files changed

+2086
-13
lines changed

docs/content/commands/npm-audit.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: Run a security audit
1111
<!-- see lib/commands/audit.js -->
1212

1313
```bash
14-
npm audit [fix]
14+
npm audit [fix|signatures]
1515
```
1616

1717
<!-- automatically generated, do not edit manually -->
@@ -41,6 +41,17 @@ vulnerability is found. It may be useful in CI environments to include the
4141
will cause the command to fail. This option does not filter the report
4242
output, it simply changes the command's failure threshold.
4343

44+
### Audit Signatures
45+
46+
This command can also audit the integrity values of the packages in your
47+
tree against any signatures present in the registry they were downloaded
48+
from. npm will attempt to download the keys from `/-/npm/v1/keys` on
49+
each the registry used to download any given package. It will then
50+
check the `dist.signatures` object in the package itself, and verify the
51+
`sig` present there using the `keyid` there, matching it with a key
52+
returned from the registry. The command for this is `npm audit
53+
signatures`
54+
4455
### Audit Endpoints
4556

4657
There are two audit endpoints that npm may use to fetch vulnerability

0 commit comments

Comments
 (0)