vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
  • audit
  • bugs
  • build
  • cache
  • ci
  • config
  • create
  • deploy
  • docs
  • exec-cache
  • exec-local
  • exec
  • help
  • init
  • install
  • list
  • login
  • logout
  • outdated
  • pack
  • ping
  • pkg
  • publish
  • query
  • registry
  • repo
  • run-exec
  • run
  • setup
  • skills
  • stage
  • token
  • trust
  • uninstall
  • update
  • version
  • view
  • whoami
  • Examples
  • Options
  • audit-level
  • view
  • target
  • workspace, workspace-group
  • What gets reported
  • How counts work
  • What is not audited
  • JSON output
  1. Client
  2. /
  3. Commands
  4. /
  5. audit

vlt audit

Usage:

Terminal
$ 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.json dependency the graph does not have, or has as another type (one moved from devDependencies to dependencies, for example)
  • a production or dev dependency missing from node_modules
  • a node_modules entry that is not the package vlt installed
  • a directory or link in node_modules that 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 one npm link made

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

Terminal
$ vlt audit

Fail on high and critical findings, or an incomplete audit

Terminal
$ vlt audit --audit-level=high

Print the report as JSON

Terminal
$ vlt audit --view=json

Audit one workspace and what it depends on

Terminal
$ vlt audit -w packages/app

Audit only what something depends on as a production dependency

Terminal
$ vlt audit --target=':prod'

Options

audit-level

The lowest severity of finding that makes the command exit with 1. Defaults to low.

Text
--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.

Text
--view=[human | json | count | markdown]
  • human: the findings, a summary, and what was and was not audited
  • json: 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 --loglevel is silent or error. It is the one view that does not name a --target query or a workspace selection
  • markdown (or agent): 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 a truncated: line that points to the human view, 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.

Text
--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.npm URL (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 the default-registry-alias one) is expected to serve the npm registry's packages. When it is neither the npm registry nor the registries.npm URL, its packages are not audited, which makes the audit incomplete: the report names the registry and the command exits with 1. This is decided from where the installed packages came from, whatever the config says now, so a later vlt install without the mirror does not hide it. A dependency that names its registry (<alias>:<name>@<range>, registry:<url>#<name>@<range>) or whose scope has one in scoped-registries is listed as not audited without making the audit incomplete.
  • Set a registry that only mirrors the public npm registry as registries.npm, and run vlt install again, to audit its packages. A single URL that serves private packages and proxies npm has no complete audit either way: as registry its npm packages are not audited, and as registries.npm its private packages have no security data. Serve the private packages from their own URL with scoped-registries, and the npm ones through registries.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

JSON
{
  "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.


Previous: CLI CommandsPrevious pageNext: bugsNext page

On this page

  • Examples
  • Options
  • audit-level
  • view
  • target
  • workspace, workspace-group
  • What gets reported
  • How counts work
  • What is not audited
  • JSON output
Edit this page

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now