vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • Reference
  • Type Aliases
  • AuditArchive
  • AuditFinding
  • AuditGraphOptions
  • AuditLevel
  • AuditPackage
  • AuditProjectOptions
  • AuditResult
  • BuildAuditOptions
  • FindFixTargetsOptions
  • FindingKind
  • FixLookup
  • FixTarget
  • SeverityLevel
  • Variables
  • auditQuery
  • severityOrder
  • Functions
  • asAuditLevel()
  • auditFails()
  • auditGraph()
  • auditJSON()
  • auditProject()
  • buildAuditResult()
  • findFixTargets()
  • formatAuditSummary()
  • incompleteReason()
  • packageLabel()
  1. Client
  2. /
  3. API Reference
  4. /
  5. @vltpkg/audit
  6. /
  7. Reference

Reference

Type Aliases

AuditArchive

TypeScript
type AuditArchive = object;

Defined in: result.ts:829

The archive lookups the audit needs.

Type declaration

NameType
get(depId) => | PackageReportData | undefined
has(depId) => boolean

AuditFinding

TypeScript
type AuditFinding = object;

Defined in: findings.ts:13

One reported alert. Every field is derived from the feed answer and checked: ids match their published formats, versions parse, text is scrubbed for terminal output.

Type declaration

NameTypeDescription
affects?stringthe affected version range, as the advisory states it
aiFlagged?truethe feed found this by AI analysis rather than a published report
alternatePackage?stringfor typosquats, the package that was probably meant
cve?string-
cvss?number-
cwes?string[]-
exploited?truelisted in CISA's Known Exploited Vulnerabilities catalog
ghsa?string-
kindFindingKind-
patched?stringthe first version the advisory says is not affected
severitySeverityLevel-
title?string-
url?string-

AuditGraphOptions

TypeScript
type AuditGraphOptions = PackageInfoClientOptions & object;

Defined in: pipeline.ts:454

Type declaration

NameTypeDescription
auditLevelAuditLevelthe lowest severity that fails the audit
graphGraphthe graph the audited packages are in
importersNode[]the audited importers: the project, or the selected workspaces
nodesReadonlySet<Node>the audited packages; importers among them are skipped
remediation?booleanLook fixes up in the registry and the security feed, for the remediation lines.
save-exact?booleana fix saves its version with no save-prefix
save-prefix?stringwhat a fix saves before its version. Defaults to ^.
signalAbortSignal-
verbose?(message) => voidcalled for diagnostics, e.g. an alert severity nobody knows
warn(message) => voidCalled for warnings: security data that could not be read or came late, fixes that could not be looked up.
within?ReadonlySet<Node>What a selection of workspaces reaches: the discovery query, the routes and the dependents stay inside it. Defaults to the whole graph.

AuditLevel

TypeScript
type AuditLevel = SeverityLevel | "none";

Defined in: alerts.ts:33

The --audit-level threshold: the lowest severity that makes the command exit 1, or none to never fail on findings.


AuditPackage

TypeScript
type AuditPackage = object;

Defined in: result.ts:771

Type declaration

NameTypeDescription
aliases?string[]the other names it is installed under, through npm: aliases
directbooleandeclared by one of the audited importers
findingsAuditFinding[]most severe first
namestring-
path?stringone route from an importer, for context
pathCountnumberhow many routes reach it
pathCountTruncatedbooleanpathCount is a floor: counting stopped at its bound
remediation?string[]What to do about it, one line each, when that can be said safely (human view)
severitySeverityLevelthe most severe of its findings
versionstring-

AuditProjectOptions

TypeScript
type AuditProjectOptions = ActualLoadOptions & Omit<AuditGraphOptions, "graph" | "importers" | "nodes" | "within"> & object;

Defined in: pipeline.ts:582

Type declaration

NameTypeDescription
target?stringAudit only the packages this DSS query selects; routes and remediation still go through the rest of the audited graph. It cannot use security selectors, and must select a package.
workspace?string[]Audit only these workspaces and what they depend on, chosen as vlt query --workspace chooses them.
workspace-group?string[]as workspace, for the workspaces in these groups

AuditResult

TypeScript
type AuditResult = object;

Defined in: result.ts:795

Type declaration

NameTypeDescription
auditLevelAuditLevel-
bundledstring[]audited packages that ship bundled dependencies
directCountnumber-
indirectCountnumber-
noDatastring[]packages the feed should know and had no data for
notAuditedstring[]packages that cannot be audited: not from the npm registry
notAuditedRegistry?stringA registry that is not the npm registry or registries.npm, and that packages a bare name led to came from: what registry or default-registry-alias pointed at when they were installed. A mirror the feed is not asked about, so the audit is incomplete.
scannedCountnumberpackages the feed had data for
summaryRecord<SeverityLevel, AuditPackage[]>flagged packages by their most severe finding
target?stringthe --target query that chose the audited packages
totalnumberhow many packages have findings
workspaces?string[]The selected workspaces, by path, when the audit covers only them and what they depend on (--workspace, --workspace-group, the directory it runs in, or vlt.json config)

BuildAuditOptions

TypeScript
type BuildAuditOptions = object;

Defined in: result.ts:837

Type declaration

NameTypeDescription
archiveAuditArchive-
auditLevelAuditLevel-
flaggedSet<DepID>the base ids of the packages the discovery query matched
importersIterable<Node>the audited importers: the project, or the selected workspaces
nodesIterable<Node>the audited packages; importers among them are skipped
subgraph?SubgraphOptionsLimits routes, path counts and dependents to the audited part of the graph, e.g. a selection of workspaces. Defaults to the whole graph.
targets?ReadonlyMap<DepID, FixTarget>The checked version to recommend, by base dep id, from findFixTargets. Packages without one get no remediation.
warn?(message) => voidcalled for diagnostics, e.g. an alert severity nobody knows

FindFixTargetsOptions

TypeScript
type FindFixTargetsOptions = object;

Defined in: result.ts:212

Type declaration

NameTypeDescription
archiveAuditArchive-
flaggedSet<DepID>the base ids of the packages the discovery query matched
importersIterable<Node>the audited importers: the project, or the selected workspaces
lookupFixLookup-
nodesIterable<Node>the audited packages; importers among them are skipped
savePrefix?stringWhat vlt install saves before a version (save-prefix, or nothing with save-exact). Defaults to ^.
subgraph?SubgraphOptionslimits dependents to the audited part of the graph

FindingKind

TypeScript
type FindingKind = "malware" | "vulnerability" | "possible-vulnerability" | "typosquat";

Defined in: alerts.ts:59

What a reported finding is. Every other alert type the feed sends is out of scope for vlt audit (it stays reachable through vlt query selectors) and never affects a package's severity.


FixLookup

TypeScript
type FixLookup = object;

Defined in: result.ts:184

What checking a fix needs from outside the graph. A lookup that fails, or answers undefined, means no fix is recommended.

Type declaration

NameTypeDescription
reports(wanted) => Promise<( | PackageReportData | undefined)[]>The security report of version of the package each node is a copy of, in order; undefined where there is none.
resolve(node, range) => Promise<string | undefined>The version an install resolves range to, for the package node is a copy of: what vlt update moves a dependent to.
versions(node) => Promise<ReadonlyMap<string, boolean> | undefined>The published versions of the package node is a copy of, each mapped to whether it is deprecated.

FixTarget

TypeScript
type FixTarget = object;

Defined in: result.ts:231

A checked version to recommend for a flagged package.

Type declaration

NameTypeDescription
rangestringWhat the fix: lines install for the importers that declare the package, and save: ${savePrefix}${version} when the version it resolves to was checked like version, else version itself.
update?Version[]What vlt update installs once the fix: lines have run, when every dependent other than the importers that declare the package allows version and each of these versions was checked like it: for those dependents, and for FixTarget.range.
updateOnly?Version[]What vlt update installs with no fix: line before it, the importers keeping the ranges they declare, when each of these versions was checked like version.
versionVersion-

SeverityLevel

TypeScript
type SeverityLevel = "critical" | "high" | "medium" | "low";

Defined in: alerts.ts:11

Variables

auditQuery

TypeScript
const auditQuery: ":malware, :vuln(<=low), :severity(<=low), :squat" = ':malware, :vuln(<=low), :severity(<=low), :squat';

Defined in: alerts.ts:8

The DSS query vlt audit finds flagged packages with. It selects every alert type in alertKinds at any level; which of a matched package's alerts are reported is then decided per alert.


severityOrder

TypeScript
const severityOrder: readonly SeverityLevel[];

Defined in: alerts.ts:14

Severity levels, most severe first.

Functions

asAuditLevel()

TypeScript
function asAuditLevel(value): AuditLevel

Defined in: alerts.ts:40

Map an --audit-level value onto an AuditLevel. npm spells medium moderate and has an info level below low; the feed has no informational grade, so info behaves as low.

Parameters

ParameterType
valueunknown

Returns

AuditLevel


auditFails()

TypeScript
function auditFails(result): boolean

Defined in: result.ts:1089

Whether the audit fails: a finding at or above the audit level, or an incomplete audit. none never fails.

Parameters

ParameterType
resultAuditResult

Returns

boolean


auditGraph()

TypeScript
function auditGraph(options): Promise<AuditResult>

Defined in: pipeline.ts:493

Audits packages of a loaded graph: reads their security data, runs the discovery query, looks fixes up when remediation is set, and builds the result.

Parameters

ParameterType
optionsAuditGraphOptions

Returns

Promise<AuditResult>


auditJSON()

TypeScript
function auditJSON(result): object

Defined in: result.ts:1104

The JSON view: the result without what only the human view shows (remediation text, AI-flagged labels), with whether the audit is auditIncomplete up front. Once released this shape is API, so it only carries what was agreed on.

Parameters

ParameterType
resultAuditResult

Returns

object

NameTypeDescription
auditLevelAuditLevel-
bundledstring[]audited packages that ship bundled dependencies
directCountnumber-
incompleteboolean-
indirectCountnumber-
noDatastring[]packages the feed should know and had no data for
notAuditedstring[]packages that cannot be audited: not from the npm registry
notAuditedRegistry?stringA registry that is not the npm registry or registries.npm, and that packages a bare name led to came from: what registry or default-registry-alias pointed at when they were installed. A mirror the feed is not asked about, so the audit is incomplete.
scannedCountnumberpackages the feed had data for
summaryRecord<SeverityLevel, Omit<AuditPackage, "remediation" | "findings"> & object[]>-
target?stringthe --target query that chose the audited packages
totalnumberhow many packages have findings
workspaces?string[]The selected workspaces, by path, when the audit covers only them and what they depend on (--workspace, --workspace-group, the directory it runs in, or vlt.json config)

auditProject()

TypeScript
function auditProject(options): Promise<AuditResult>

Defined in: pipeline.ts:608

Audits the install in projectRoot as vlt audit does: refuses an install vlt did not make or another client changed since, loads it with every workspace, selects the importers and the target, then runs auditGraph.

Parameters

ParameterType
optionsAuditProjectOptions

Returns

Promise<AuditResult>


buildAuditResult()

TypeScript
function buildAuditResult(__namedParameters): AuditResult

Defined in: result.ts:939

Build the audit result: classify every package by what is known about it, then turn the alerts of the flagged ones into findings.

Packages are keyed by their base dep id, so one installed in several peer contexts is counted and reported once.

Parameters

ParameterType
__namedParametersBuildAuditOptions

Returns

AuditResult


findFixTargets()

TypeScript
function findFixTargets(__namedParameters): Promise<Map<DepID, FixTarget>>

Defined in: result.ts:337

The version to recommend, by base dep id, for every flagged package whose findings a newer version can fix: vulnerabilities, with no malware or typosquat among them.

The candidate is the lowest published release at or above every advisory's first patched version, outside every affected range, and not deprecated. It is then looked up in the feed: when it has vulnerabilities of its own the search goes on above them, at most maxFixRounds candidates in all. A candidate with any other finding, one the feed has no data for, or a lookup that fails ends the search with no fix, so a recommended version is never one the audit would flag.

What a fix: line saves is ${savePrefix}${version} when the version that range resolves to is checked the same way, else the version itself. When every other dependent allows the version, the versions vlt update would move them to are checked the same way, since they are usually newer than the one recommended; and when the ranges already declared resolve to checked versions, vlt update alone is the fix. With a selection of workspaces there is no vlt update check: it would also move the unselected ones.

Parameters

ParameterType
__namedParametersFindFixTargetsOptions

Returns

Promise<Map<DepID, FixTarget>>


formatAuditSummary()

TypeScript
function formatAuditSummary(result, __namedParameters): string

Defined in: human-view.ts:235

The human view. Findings first and the summary last, so the counts are on screen when a long report ends; then what was audited and what was not, always.

Parameters

ParameterType
resultAuditResult
__namedParameters{ colors: boolean; }
__namedParameters.colors?boolean

Returns

string


incompleteReason()

TypeScript
function incompleteReason(result): undefined | string

Defined in: result.ts:1068

Why the audit is incomplete, when it is.

Parameters

ParameterType
resultAuditResult

Returns

undefined | string


packageLabel()

TypeScript
function packageLabel(pkg): string

Defined in: result.ts:1132

name@version, and the alias names it is installed under

Parameters

ParameterType
pkgAuditPackage

Returns

string


Previous: @vltpkg/auditPrevious pageNext: @vltpkg/cacheNext page

On this page

  • Type Aliases
  • AuditArchive
  • AuditFinding
  • AuditGraphOptions
  • AuditLevel
  • AuditPackage
  • AuditProjectOptions
  • AuditResult
  • BuildAuditOptions
  • FindFixTargetsOptions
  • FindingKind
  • FixLookup
  • FixTarget
  • SeverityLevel
  • Variables
  • auditQuery
  • severityOrder
  • Functions
  • asAuditLevel()
  • auditFails()
  • auditGraph()
  • auditJSON()
  • auditProject()
  • buildAuditResult()
  • findFixTargets()
  • formatAuditSummary()
  • incompleteReason()
  • packageLabel()

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