vlt audit
Usage:
$ vlt audit
$ vlt audit [--audit-level=<level>] [--target=<query>] [--view=human | json | count | markdown]Check installed dependencies for malware, known vulnerabilities, possible vulnerabilities and typosquats.
The audited graph is the one built by vlt install. The command
errors instead of reporting a clean result in a project installed by
another client, not installed at all, or changed since:
- a
package.jsondependency the graph does not have, or has as another type (one moved fromdevDependenciestodependencies, for example) - a production or dev dependency missing from
node_modules - a
node_modulesentry that is not the package vlt installed - a directory or link in
node_modulesthat vlt did not install, such as an optional dependency it left out - a link to a folder outside vlt's store that is not a
file:,link:or workspace dependency, such as onenpm linkmade
Each error says what to do. vlt install leaves entries it does not
know in place: remove them, or remove node_modules and install
again.
The human and json views print every finding; the markdown view
lists up to five per package and says how many more there are. The
command exits with 1 when a finding is at or above --audit-level,
or when the audit is incomplete (a package that should have security
data has none, or packages come from a default registry that is not
audited), unless the level is none, so it can gate CI directly.
Otherwise it exits with 0.
Examples
Audit all installed dependencies
$ vlt auditFail on high and critical findings, or an incomplete audit
$ vlt audit --audit-level=highPrint the report as JSON
$ vlt audit --view=jsonAudit one workspace and what it depends on
$ vlt audit -w packages/appAudit only what something depends on as a production dependency
$ vlt audit --target=':prod'Options
audit-level
The lowest severity of finding that makes the command exit with 1.
Defaults to low.
--audit-level=[info | low | moderate | medium | high | critical | none]As with npm audit, the level does not filter the report: the same
findings are printed at every level. An incomplete audit fails at
every level but none. medium is accepted as the same as
moderate, and info behaves as low, the lowest grade the security
data uses. none fails on neither findings nor an incomplete audit; a
usage error, or an install the command refuses to audit, still exits
with 1.
view
Output format. Defaults to human-readable, or json if no tty.
--view=[human | json | count | markdown]human: the findings, a summary, and what was and was not auditedjson: the same report as an object (see below)count: the number of packages with findings; an incomplete audit also prints a warning on stderr, unless--loglevelissilentorerror. It is the one view that does not name a--targetquery or a workspace selectionmarkdown(oragent): the result, what made the audit incomplete and a table of the packages with findings, for a coding agent to read. Like every markdown view it is cut to 16,000 characters, which drops the least severe rows under atruncated:line that points to thehumanview, the one with every finding and fix
target
Audit only the packages a
Dependency Selector Syntax query selects. Routes
and remediation still go through the rest of the audited graph (all of
it, or what the selected workspaces reach). The query cannot use
security selectors such as
:scanned or :malware: what is audited must not depend on the
security data. A query that selects no installed package is an error,
like a mistyped workspace. Every view but count names the query.
--scope is ignored, with a warning. Both are read from the command
line and the environment only, not from vlt.json.
:prod selects every package that something depends on as a
production dependency. It is not npm's --omit=dev: what a dev
dependency depends on stays in, and packages reached only through
optional or peer dependencies, such as platform-specific binaries, are
left out.
--target=<query>workspace, workspace-group
Audit only the selected workspaces and the packages they depend on,
the way vlt query applies them. Run from inside a workspace
directory, or with a workspace set in vlt.json, the audit covers
that selection too. Every view but count names the selected
workspaces, and a value that matches no workspace is an error, also
next to ones that do.
In a narrowed audit, the errors for an install another client changed
compare the package.json of the audited workspaces only, and check
the node_modules of the audited workspaces, of the root, and of any
workspace whose folder holds, or is, the folder of an audited
workspace or file: dependency, since Node loads from there what a
package's own node_modules lacks.
What gets reported
Security data comes from Socket and four kinds of finding are reported:
- malware, always graded critical
- vulnerability: a published advisory (CVE or GHSA)
- possible vulnerability: found by analysis, before any advisory
- possible typosquat: a name close to a popular package, with the package that was probably meant
Malware and vulnerabilities are always reported. The security data marks some analysis findings as not worth reporting once reviewed; those possible vulnerabilities and typosquats are left out. Other alerts (deprecation, install scripts, network access and the like) are not part of the audit and do not affect a package's severity; query them with the security selectors.
Each package is graded by its most severe finding. Findings listed by CISA as actively exploited are marked, and counted in the summary.
When it is safe to recommend one, a package gets remediation lines. The version is the lowest published release at or above the first patched versions its advisories name, outside every affected range and not deprecated. It is looked up in the security data too: when it has vulnerabilities of its own, the search goes on above them, and when it has any other finding or no data, there is no remediation.
A direct dependency whose declared ranges already reach a checked
version gets fix: vlt update <name> (installs <versions>): what
vlt update installs for every copy, each version checked the same
way, while package.json keeps the ranges it declares (*, latest,
"" or ^4.17.1 alike). Otherwise it gets
fix: vlt install <name>@^<version>, the range vlt install then
saves (with save-prefix when it is ^, ~, >= or =, quoted for
the shell when it is >=; nothing with save-exact), one line per
workspace that declares it (with -w <path>); when that range
resolves to a version that is not clean, the line names the version
itself. Either is shown as fix (semver-major): when a version is
outside the caret range of the installed one. There is none when the
package is declared through an alias, catalog: or workspace:, or
as both a dev and a peer dependency, and no remediation at all for a
package whose version a graph modifier chooses. When other packages
depend on it too, a further line says whether their declared ranges
allow the version. A transitive dependency gets that line alone:
reachable: when every dependent allows the version, with the
versions vlt update <name> installs for them and for the range the
fix: line saves (usually newer, and checked the same way: no line
when one of them is not), or blocked: with the dependents that hold
it back. When a dependent declares no range (a git or file: spec, a
dist-tag) and none blocks the version, nothing can be said for all of
them: a transitive dependency gets no line, and a direct one no
remediation at all. The reachable: line names no command when a copy
of the package is only installed through an npm: alias, which
vlt update <name> does not select. With --workspace or
--workspace-group, it says "every dependent in the audited
selection" and names no command, since vlt update would also reach
the workspaces left out. Otherwise each advisory shows its own patched
version.
Remediation is looked up, in the registry and the security data, only
for the views that print it: human and markdown. The lookups get
30 seconds in all; one that fails or runs out of time leaves its
package without remediation, and a warning on stderr says that a
package may show no fix where there is one.
How counts work
The summary counts packages with findings. npm audit also counts
every package that depends on a vulnerable one, so its totals are
usually higher for the same tree.
What is not audited
- Packages that do not come from the npm registry or the
registries.npmURL (git, remote tarballs,file:and packages from other configured registries) have no security data. They are listed as not audited, and do not fail the run. - The registry that bare package names resolved through when they were
installed (
registry, or thedefault-registry-aliasone) is expected to serve the npm registry's packages. When it is neither the npm registry nor theregistries.npmURL, its packages are not audited, which makes the audit incomplete: the report names the registry and the command exits with1. This is decided from where the installed packages came from, whatever the config says now, so a latervlt installwithout the mirror does not hide it. A dependency that names its registry (<alias>:<name>@<range>,registry:<url>#<name>@<range>) or whose scope has one inscoped-registriesis listed as not audited without making the audit incomplete. - Set a registry that only mirrors the public npm registry as
registries.npm, and runvlt installagain, to audit its packages. A single URL that serves private packages and proxies npm has no complete audit either way: asregistryits npm packages are not audited, and asregistries.npmits private packages have no security data. Serve the private packages from their own URL withscoped-registries, and the npm ones throughregistries.npm. - Dependencies bundled inside another package's tarball are not part of the graph. Packages that bundle dependencies are listed.
A package from the npm registry that has no security data (published
minutes ago, or the security service could not be reached) makes the
audit incomplete: the report says so, names it, and the command exits
with 1.
Security data is cached for three hours. Older cache entries are fetched again before the report is printed. Audits run at the same time share the cache, each waiting for the other to finish writing it. When the cache file cannot be used at all, the error names it.
JSON output
{
"auditLevel": "low",
"incomplete": false,
"summary": {
"critical": [],
"high": [
{
"name": "lodash",
"version": "4.17.15",
"severity": "high",
"direct": true,
"path": "my-project > lodash",
"pathCount": 1,
"pathCountTruncated": false,
"findings": [
{
"kind": "vulnerability",
"severity": "high",
"cve": "CVE-2021-23337",
"ghsa": "GHSA-35jh-r3h4-6jhm",
"title": "Command Injection in lodash",
"affects": "< 4.17.21",
"patched": "4.17.21"
}
]
}
],
"medium": [],
"low": []
},
"total": 1,
"directCount": 1,
"indirectCount": 0,
"scannedCount": 1,
"noData": [],
"notAudited": [],
"bundled": []
}A finding's kind is malware, vulnerability,
possible-vulnerability or typosquat, and its severity one of
low, medium, high and critical. Other finding fields are
present when known: cve, ghsa, url, title, cvss, cwes,
affects, patched, exploited and alternatePackage. A package
installed under another name through an npm: alias lists those names
in aliases. noData and notAudited list name@version of the
packages without security data and of those that cannot be audited,
and bundled the audited packages whose bundled dependencies were not
audited. notAuditedRegistry, when present, is the registry bare
names resolve through whose packages were not audited. incomplete is
true when a package has no security data or notAuditedRegistry is
set. target is the --target query, and workspaces the paths of
the selected workspaces, when the audit was narrowed by them.
auditLevel is the level the run used, normalized: info is low
and moderate is medium.