You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10,38 +10,23 @@ description: Run a security audit
10
10
11
11
### Description
12
12
13
-
The audit command submits a description of the dependencies configured in
14
-
your project to your default registry and asks for a report of known
15
-
vulnerabilities.
16
-
If any vulnerabilities are found, then the impact and
17
-
appropriate remediation will be calculated.
18
-
If the `fix` argument is
19
-
provided, then remediations will be applied to the package tree.
13
+
The audit command submits a description of the dependencies configured in your project to your default registry and asks for a report of known vulnerabilities.
14
+
If any vulnerabilities are found, then the impact and appropriate remediation will be calculated.
15
+
If the `fix` argument is provided, then remediations will be applied to the package tree.
20
16
21
17
The command will exit with a 0 exit code if no vulnerabilities were found.
22
18
23
-
Note that some vulnerabilities cannot be fixed automatically and will
24
-
require manual intervention or review.
25
-
Also note that since `npm audit
26
-
fix` runs a full-fledged `npm install` under the hood, all configs that
27
-
apply to the installer will also apply to `npm install` -- so things like
28
-
`npm audit fix --package-lock-only` will work as expected.
29
-
30
-
By default, the audit command will exit with a non-zero code if any
31
-
vulnerability is found.
32
-
It may be useful in CI environments to include the
33
-
`--audit-level` parameter to specify the minimum vulnerability level that
34
-
will cause the command to fail.
35
-
This option does not filter the report
36
-
output, it simply changes the command's failure threshold.
19
+
Note that some vulnerabilities cannot be fixed automatically and will require manual intervention or review.
20
+
Also note that since `npm audit fix` runs a full-fledged `npm install` under the hood, all configs that apply to the installer will also apply to `npm install` -- so things like `npm audit fix --package-lock-only` will work as expected.
21
+
22
+
By default, the audit command will exit with a non-zero code if any vulnerability is found.
23
+
It may be useful in CI environments to include the `--audit-level` parameter to specify the minimum vulnerability level that will cause the command to fail.
24
+
This option does not filter the report output, it simply changes the command's failure threshold.
37
25
38
26
### Package lock
39
27
40
-
By default npm requires a package-lock or shrinkwrap in order to run the
41
-
audit.
42
-
You can bypass the package lock with `--no-package-lock` but be
43
-
aware the results may be different with every run, since npm will
44
-
re-build the dependency tree each time.
28
+
By default npm requires a package-lock or shrinkwrap in order to run the audit.
29
+
You can bypass the package lock with `--no-package-lock` but be aware the results may be different with every run, since npm will re-build the dependency tree each time.
45
30
46
31
### Audit Signatures
47
32
@@ -53,14 +38,9 @@ Registry signatures can be verified using the following `audit` command:
53
38
$ npm audit signatures
54
39
```
55
40
56
-
The `audit signatures` command will also verify the provenance attestations of
57
-
downloaded packages.
58
-
Because provenance attestations are such a new feature,
59
-
security features may be added to (or changed in) the attestation format over
60
-
time.
61
-
To ensure that you're always able to verify attestation signatures check
62
-
that you're running the latest version of the npm CLI. Please note this often
63
-
means updating npm beyond the version that ships with Node.js.
41
+
The `audit signatures` command will also verify the provenance attestations of downloaded packages.
42
+
Because provenance attestations are such a new feature, security features may be added to (or changed in) the attestation format over time.
43
+
To ensure that you're always able to verify attestation signatures check that you're running the latest version of the npm CLI. Please note this often means updating npm beyond the version that ships with Node.js.
64
44
65
45
The npm CLI supports registry signatures and signing keys provided by any registry if the following conventions are followed:
66
46
@@ -106,44 +86,29 @@ See this [example key's response from the public npm registry](https://registry.
106
86
107
87
### Audit Endpoints
108
88
109
-
There are two audit endpoints that npm may use to fetch vulnerability
110
-
information: the `Bulk Advisory` endpoint and the `Quick Audit` endpoint.
89
+
There are two audit endpoints that npm may use to fetch vulnerability information: the `Bulk Advisory` endpoint and the `Quick Audit` endpoint.
111
90
112
91
#### Bulk Advisory Endpoint
113
92
114
-
As of version 7, npm uses the much faster `Bulk Advisory` endpoint to
115
-
optimize the speed of calculating audit results.
93
+
As of version 7, npm uses the much faster `Bulk Advisory` endpoint to optimize the speed of calculating audit results.
116
94
117
-
npm will generate a JSON payload with the name and list of versions of each
118
-
package in the tree, and POST it to the default configured registry at
119
-
the path `/-/npm/v1/security/advisories/bulk`.
95
+
npm will generate a JSON payload with the name and list of versions of each package in the tree, and POST it to the default configured registry at the path `/-/npm/v1/security/advisories/bulk`.
120
96
121
-
Any packages in the tree that do not have a `version` field in their
122
-
package.json file will be ignored.
123
-
If any `--omit` options are specified
124
-
(either via the [`--omit` config](/using-npm/config#omit), or one of the
125
-
shorthands such as `--production`, `--only=dev`, and so on), then packages will
126
-
be omitted from the submitted payload as appropriate.
97
+
Any packages in the tree that do not have a `version` field in their package.json file will be ignored.
98
+
If any `--omit` options are specified (either via the [`--omit` config](/using-npm/config#omit), or one of the shorthands such as `--production`, `--only=dev`, and so on), then packages will be omitted from the submitted payload as appropriate.
127
99
128
-
If the registry responds with an error, or with an invalid response, then
129
-
npm will attempt to load advisory data from the `Quick Audit` endpoint.
100
+
If the registry responds with an error, or with an invalid response, then npm will attempt to load advisory data from the `Quick Audit` endpoint.
130
101
131
-
The expected result will contain a set of advisory objects for each
132
-
dependency that matches the advisory range.
133
-
Each advisory object contains
134
-
a `name`, `url`, `id`, `severity`, `vulnerable_versions`, and `title`.
102
+
The expected result will contain a set of advisory objects for each dependency that matches the advisory range.
103
+
Each advisory object contains a `name`, `url`, `id`, `severity`, `vulnerable_versions`, and `title`.
135
104
136
-
npm then uses these advisory objects to calculate vulnerabilities and
137
-
meta-vulnerabilities of the dependencies within the tree.
105
+
npm then uses these advisory objects to calculate vulnerabilities and meta-vulnerabilities of the dependencies within the tree.
138
106
139
107
#### Quick Audit Endpoint
140
108
141
-
If the `Bulk Advisory` endpoint returns an error, or invalid data, npm will
142
-
attempt to load advisory data from the `Quick Audit` endpoint, which is
143
-
considerably slower in most cases.
109
+
If the `Bulk Advisory` endpoint returns an error, or invalid data, npm will attempt to load advisory data from the `Quick Audit` endpoint, which is considerably slower in most cases.
144
110
145
-
The full package tree as found in `package-lock.json` is submitted, along
146
-
with the following pieces of additional metadata:
111
+
The full package tree as found in `package-lock.json` is submitted, along with the following pieces of additional metadata:
147
112
148
113
*`npm_version`
149
114
*`node_version`
@@ -156,67 +121,42 @@ Omitted dependency types are skipped when generating the report.
156
121
157
122
#### Scrubbing
158
123
159
-
Out of an abundance of caution, npm versions 5 and 6 would "scrub" any
160
-
packages from the submitted report if their name contained a `/` character,
161
-
so as to avoid leaking the names of potentially private packages or git
162
-
URLs.
124
+
Out of an abundance of caution, npm versions 5 and 6 would "scrub" any packages from the submitted report if their name contained a `/` character, so as to avoid leaking the names of potentially private packages or git URLs.
163
125
164
-
However, in practice, this resulted in audits often failing to properly
165
-
detect meta-vulnerabilities, because the tree would appear to be invalid
166
-
due to missing dependencies, and prevented the detection of vulnerabilities
167
-
in package trees that used git dependencies or private modules.
126
+
However, in practice, this resulted in audits often failing to properly detect meta-vulnerabilities, because the tree would appear to be invalid due to missing dependencies, and prevented the detection of vulnerabilities in package trees that used git dependencies or private modules.
168
127
169
128
This scrubbing has been removed from npm as of version 7.
170
129
171
130
#### Calculating Meta-Vulnerabilities and Remediations
module to turn a set of security advisories into a set of "vulnerability"
176
-
objects.
177
-
A "meta-vulnerability" is a dependency that is vulnerable by
178
-
virtue of dependence on vulnerable versions of a vulnerable package.
132
+
npm uses the [`@npmcli/metavuln-calculator`](http://npm.im/@npmcli/metavuln-calculator) module to turn a set of security advisories into a set of "vulnerability" objects.
133
+
A "meta-vulnerability" is a dependency that is vulnerable by virtue of dependence on vulnerable versions of a vulnerable package.
179
134
180
-
For example, if the package `foo` is vulnerable in the range `>=1.0.2
181
-
<2.0.0`, and the package `bar` depends on `foo@^1.1.0`, then that version
182
-
of `bar` can only be installed by installing a vulnerable version of `foo`.
135
+
For example, if the package `foo` is vulnerable in the range `>=1.0.2 <2.0.0`, and the package `bar` depends on `foo@^1.1.0`, then that version of `bar` can only be installed by installing a vulnerable version of `foo`.
183
136
In this case, `bar` is a "metavulnerability".
184
137
185
-
Once metavulnerabilities for a given package are calculated, they are
186
-
cached in the `~/.npm` folder and only re-evaluated if the advisory range
187
-
changes, or a new version of the package is published (in which case, the
188
-
new version is checked for metavulnerable status as well).
138
+
Once metavulnerabilities for a given package are calculated, they are cached in the `~/.npm` folder and only re-evaluated if the advisory range changes, or a new version of the package is published (in which case, the new version is checked for metavulnerable status as well).
189
139
190
-
If the chain of metavulnerabilities extends all the way to the root
191
-
project, and it cannot be updated without changing its dependency ranges,
192
-
then `npm audit fix` will require the `--force` option to apply the
193
-
remediation.
194
-
If remediations do not require changes to the dependency
195
-
ranges, then all vulnerable packages will be updated to a version that does
196
-
not have an advisory or metavulnerability posted against it.
140
+
If the chain of metavulnerabilities extends all the way to the root project, and it cannot be updated without changing its dependency ranges, then `npm audit fix` will require the `--force` option to apply the remediation.
141
+
If remediations do not require changes to the dependency ranges, then all vulnerable packages will be updated to a version that does not have an advisory or metavulnerability posted against it.
197
142
198
143
### Exit Code
199
144
200
-
The `npm audit` command will exit with a 0 exit code if no vulnerabilities
201
-
were found.
202
-
The `npm audit fix` command will exit with 0 exit code if no
203
-
vulnerabilities are found _or_ if the remediation is able to successfully
204
-
fix all vulnerabilities.
145
+
The `npm audit` command will exit with a 0 exit code if no vulnerabilities were found.
146
+
The `npm audit fix` command will exit with 0 exit code if no vulnerabilities are found _or_ if the remediation is able to successfully fix all vulnerabilities.
205
147
206
148
If vulnerabilities were found the exit code will depend on the
Copy file name to clipboardExpand all lines: docs/lib/content/commands/npm-bugs.md
+2-6Lines changed: 2 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,8 @@ description: Report bugs for a package in a web browser
10
10
11
11
### Description
12
12
13
-
This command tries to guess at the likely location of a package's bug
14
-
tracker URL or the `mailto` URL of the support email, and then tries to
15
-
open it using the [`--browser` config](/using-npm/config#browser) param.
16
-
If no
17
-
package name is provided, it will search for a `package.json` in the current
18
-
folder and use the `name` property.
13
+
This command tries to guess at the likely location of a package's bug tracker URL or the `mailto` URL of the support email, and then tries to open it using the [`--browser` config](/using-npm/config#browser) param.
14
+
If no package name is provided, it will search for a `package.json` in the current folder and use the `name` property.
Copy file name to clipboardExpand all lines: docs/lib/content/commands/npm-completion.md
+4-10Lines changed: 4 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,25 +12,19 @@ description: Tab Completion for npm
12
12
13
13
Enables tab-completion in all npm commands.
14
14
15
-
The synopsis above
16
-
loads the completions into your current shell.
17
-
Adding it to
18
-
your ~/.bashrc or ~/.zshrc will make the completions available
19
-
everywhere:
15
+
The synopsis above loads the completions into your current shell.
16
+
Adding it to your ~/.bashrc or ~/.zshrc will make the completions available everywhere:
20
17
21
18
```bash
22
19
npm completion >>~/.bashrc
23
20
npm completion >>~/.zshrc
24
21
```
25
22
26
-
You may of course also pipe the output of `npm completion` to a file
27
-
such as `/usr/local/etc/bash_completion.d/npm` or
23
+
You may of course also pipe the output of `npm completion` to a file such as `/usr/local/etc/bash_completion.d/npm` or
28
24
`/etc/bash_completion.d/npm` if you have a system that will read
29
25
that file for you.
30
26
31
-
When `COMP_CWORD`, `COMP_LINE`, and `COMP_POINT` are defined in the
32
-
environment, `npm completion` acts in "plumbing mode", and outputs
33
-
completions based on the arguments.
27
+
When `COMP_CWORD`, `COMP_LINE`, and `COMP_POINT` are defined in the environment, `npm completion` acts in "plumbing mode", and outputs completions based on the arguments.
0 commit comments