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
Copy file name to clipboardexpand all lines: docs/lib/content/using-npm/dependency-selectors.md
+17-1
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ The [`npm query`](/commands/npm-query) command exposes a new dependency selector
13
13
- Unlocks the ability to answer complex, multi-faceted questions about dependencies, their relationships & associative metadata
14
14
- Consolidates redundant logic of similar query commands in `npm` (ex. `npm fund`, `npm ls`, `npm outdated`, `npm audit` ...)
15
15
16
-
### Dependency Selector Syntax`v1.0.0`
16
+
### Dependency Selector Syntax
17
17
18
18
#### Overview:
19
19
@@ -62,6 +62,7 @@ The [`npm query`](/commands/npm-query) command exposes a new dependency selector
62
62
-`:path(<path>)`[glob](https://www.npmjs.com/package/glob) matching based on dependencies path relative to the project
63
63
-`:type(<type>)`[based on currently recognized types](https://github.com/npm/npm-package-arg#result-object)
64
64
-`:outdated(<type>)` when a dependency is outdated
65
+
-`:vuln(<selector>)` when a dependency has a known vulnerability
65
66
66
67
##### `:semver(<spec>, [selector], [function])`
67
68
@@ -101,6 +102,21 @@ Some examples:
101
102
-`:root > :outdated(major)` returns every direct dependency that has a new semver major release
102
103
-`.prod:outdated(in-range)` returns production dependencies that have a new release that satisfies at least one of its parent's dependencies
103
104
105
+
##### `:vuln`
106
+
107
+
The `:vuln` pseudo selector retrieves data from the registry and returns information about which if your dependencies has a known vulnerability. Only dependencies whose current version matches a vulnerability will be returned. For example if you have `semver@7.6.0` in your tree, a vulnerability for `semver` which affects versions `<=6.3.1` will not match.
108
+
109
+
You can also filter results by certain attributes in advisories. Currently that includes `severity` and `cwe`. Note that severity filtering is done per severity, it does not include severities "higher" or "lower" than the one specified.
110
+
111
+
In addition to the filtering performed by the pseudo selector, info about each relevant advisory will be added to the `queryContext` attribute of each node under the `advisories` attribute.
112
+
113
+
Some examples:
114
+
115
+
-`:root > .prod:vuln` returns direct production dependencies with any known vulnerability
116
+
-`:vuln([severity=high])` returns only dependencies with a vulnerability with a `high` severity.
117
+
-`:vuln([severity=high],[severity=moderate])` returns only dependencies with a vulnerability with a `high` or `moderate` severity.
118
+
-`:vuln([cwe=1333])` returns only dependencies with a vulnerability that includes CWE-1333 (ReDoS)
0 commit comments