pnpm audit
Перевіряє наявність відомих проблем безпеки у встановлених пакунках.
Якщо виявлено проблеми з безпекою, спробуйте оновити залежності за допомогою pnpm update.
Якщо звичайне оновлення не може виправити всі проблеми, використайте перевизначення overrides, для примусового встановлення версій, які не є вразливими. Наприклад, якщо бібліотека lodash@<2.1.0 є вразливою, скористайтеся цим перевизначенням для встановлення lodash@^2.1.0:
overrides:
"lodash@<2.1.0": "^2.1.0"
Або, запустіть pnpm audit --fix.
Якщо ви хочете проігнорувати деякі вразливості, оскільки вони не впливають на ваш проєкт, ви можете використати параметр audit.ignore.
pnpm audit queries the registry's /-/npm/v1/security/advisories/bulk endpoint. The response does not include CVE identifiers, so advisories are identified by the GitHub advisory ID (GHSA) in their URL.
The command exits with code 1 when an advisory at or above the audit level remains after ignored advisories are removed. This also applies to --ignore and --ignore-unfixable, which save the IDs first.
Команди#
signatures#
pnpm audit signatures
Verifies the ECDSA registry signatures of installed registry packages against the public keys each registry publishes at /-/npm/v1/keys. pnpm respects scoped and prefix-routed registries configured via registries, and skips registries that do not publish signing keys as well as tarball, git, and directory dependencies.
Signatures are verified against the package integrity recorded in the lockfile. A package without recorded integrity cannot pass verification.
A registry signs the integrity of a package's .tgz. When the lockfile pins tars with lockfile.integrityTarget: tar, the signature is verified against the .tgz integrity the registry publishes, once pnpm has tied it to the tar hash in the lockfile. The store answers for a package it holds. Any other package is downloaded and checked. A package that cannot be tied is reported as invalid, with the reason.
Команда завершує роботу з кодом помилки 1, якщо будь-який пакунок має недійсний підпис, або якщо реєстр оголошує наявність ключів підпису, але пакунок був опублікований без підпису. Використовуйте разом з опцією --json, щоб отримати вихідні дані у форматі, придатному для машинного зчитування.
deprecations#
pnpm audit deprecations
Lists the installed packages that their registry marks as deprecated, with the message the publisher left. Each package shows the projects that depend on it directly, or a chain of packages that brings it in. When the package has a version that is not deprecated, the newest one is named.
pnpm reads registry metadata from its cache when that metadata is less than 5 minutes old, so right after an install no requests are needed. Older metadata is checked against the registry, so a package deprecated since then is reported. Tarball, git, and directory dependencies are skipped.
The command exits with code 1 if any installed package is deprecated. --prod, --dev, --no-optional, --json, --ignore-registry-errors, and workspace filters apply to it.
engines#
pnpm audit engines
Lists the installed packages that don't support the current Node.js version or platform, with what each one wants. Each package shows the projects that depend on it directly, or a chain of packages that brings it in. These are the packages an install warns about.
pnpm checks the packages against the Node.js version an install uses: the nodeVersion setting, the Node.js version the lockfile pins for the root project, or the system Node.js. The platform includes supportedArchitectures. An optional dependency that an install skips is not listed. The command reads the lockfile and makes no registry requests.
The command exits with code 1 if any installed package is incompatible. --prod, --dev, --no-optional, --json, and workspace filters apply to it.
Параметри#
--audit-level <severity>#
- Type: info, low, moderate, high, critical
- Стандартно: low
Виводить лише ті попередження, серйозність яких більша або дорівнює <severity>. Advisories below this level also do not fail the command.
This can also be set via audit.level in pnpm-workspace.yaml.
--fix#
Add overrides to the pnpm-workspace.yaml file to force non-vulnerable versions of the dependencies.
Use --fix=update to fix vulnerabilities by updating the vulnerable packages in the lockfile instead of adding overrides.
When minimumReleaseAge would block the minimum patched version, --fix adds it to minimumReleaseAgeExclude in pnpm-workspace.yaml so it can be installed.
--no-add-release-age-exclusions#
Skip automatic additions to minimumReleaseAgeExclude for both fix methods and interactive fixes. The release age policy can still block recently published patches unless an existing exclusion allows them. If the resolver selects a patch that the age policy blocks, --fix=update can exit with ERR_PNPM_NO_MATURE_MATCHING_VERSION. With --fix=update, the update still follows minimumReleaseAgeExcludePrune.
--interactive, -i#
Перегляньте повідомлення, відібрані з --fix, і виберіть ті, які потрібно застосувати. Implies --fix=override when --fix is not given.
--json#
Виводить на екран результат перевірки у форматі JSON.
patched_versions is null for an advisory with no published fix, so tooling can tell "no fix available" from "fix available at version X".
--dev, -D#
Перевіряє лише dev залежності.
--prod, --production, -P#
Only audit dependencies and optionalDependencies.
--optional#
Audit optionalDependencies. This is the default.
--no-optional#
Не перевіряти optional Dependencies.
--ignore-registry-errors#
Якщо реєстр повертає код статусу, відмінний від 200, процес повинен завершитися з 0. Таким чином, процес завершиться невдачею лише у випадку, якщо реєстр успішно відповість і знайде вразливості.
--ignore-unfixable#
Ігноруйте всі повідомлення, для яких не знайдено вирішення. An unfixable advisory without a GHSA ID cannot be ignored and fails the command with ERR_PNPM_AUDIT_MISSING_GHSA.
Their GHSA IDs are saved in pnpm-workspace.yaml the same way as with --ignore.
--ignore <vulnerability>#
Ігнорувати вразливість за її ідентифікатором повідомлення на GitHub (GHSA).
The ID is saved in pnpm-workspace.yaml, which is created if missing, and no audit report is printed. It is added to audit.ignore if that list is already set, otherwise to the deprecated auditConfig.ignoreGhsas, which pnpm still reads. To have a new project write to audit.ignore, create the list first (audit: { ignore: [] }).
Налаштування#
pnpm audit is configured in the audit section of pnpm-workspace.yaml:
audit:
level: high
ignore:
- GHSA-42xw-2xvc-qx8m
audit.level#
- Стандартно: low
- Type: info, low, moderate, high, critical
Виводити на екран лише попередження, рівень серйозності яких дорівнює або перевищує цей рівень. Same as the --audit-level flag.
audit.ignore#
A list of GHSA codes that will be ignored by the pnpm audit command.
audit:
ignore:
- GHSA-42xw-2xvc-qx8m
- GHSA-4w2v-q235-vp99
- GHSA-cph5-m8f7-6c5x
- GHSA-vh95-rmgr-6w4m
Since v12.4.0, ignored advisories are left out of the vulnerability total and the per-severity counts, and reported separately. When every advisory found is ignored, the summary says so rather than reporting a clean audit.
audit.ignorePrune#
Added in: v12.0.0
- Стандартно: false
- Тип: Boolean
When true, pnpm audit --fix removes the audit.ignore
entries whose GHSA no longer appears in the audit report, so a list of tolerated
advisories doesn't accumulate entries for dependencies that are long gone.
audit:
ignorePrune: true
інформація
auditLevel and auditConfig.ignoreGhsas are deprecated names for audit.level and audit.ignore, and pnpm still reads them. When both spellings are set, the audit section takes precedence and a warning is printed.
auditConfig.ignoreCves is not recognized. Replace each CVE with the matching GHSA-xxxx-xxxx-xxxx ID, shown in the More info column of pnpm audit output, under audit.ignore.