Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(ci): excuse an unfixable advisory by id instead of lowering the audit bar
Yudhi Armyndharis0809db8f7fd5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 36551e786..7334e56ca 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -103,10 +103,11 @@ jobs:run: npm ci- name: Security audit- # high (not critical): the `overrides` in package.json clear the root tree's HIGH advisories- # (brace-expansion CVE-2026-14257, js-yaml GHSA-pm4m-ph32-ghv5), so this threshold now fences- # HIGH regressions instead of only catching criticals.- run: npm audit --audit-level=high+ # Same high (not critical) threshold, applied per advisory rather than all-or-nothing: an+ # advisory with no patched version can be excused BY ID in scripts/check-audit.mjs, with its+ # reason recorded, instead of lowering the bar for everything. The script also fails on an+ # allowlist entry whose advisory has gone, so a carve-out cannot outlive its cause.+ run: npm run check:audit# The dashboard is a SECOND dependency tree, and it is the one that reaches a browser: its# runtime deps are bundled into dashboard/dist, which the production image copies and serves.diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 34040bbc1..92b31a5b8 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -63,9 +63,11 @@ jobs:echo "Tag $TAG matches package.json $PKG_VERSION"- name: Security audit- # Matches ci.yml's threshold: high (not critical). The release gate must not be laxer than the- # PR gate, or a HIGH advisory blocked on every PR would still sail through at tag time.- run: npm audit --audit-level=high+ # Matches ci.yml exactly, including its per-advisory allowlist. The release gate must not be+ # laxer than the PR gate, or a HIGH advisory blocked on every PR would still sail through at+ # tag time — and it must not be STRICTER either, or a tag fails on something main has already+ # accepted, which is how a release stalls with nothing actionable to fix.+ run: npm run check:audit# Second tree, same rule. The dashboard's runtime deps are bundled into dashboard/dist and the# published image serves them to every operator's browser, so the tag path must scan them fordiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 584eab646..8cf6390d6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Changed++- The root tree's dependency audit now applies its `high` threshold per advisory instead of all-or-nothing, via `npm run check:audit`. `GHSA-jmr9-qjv8-65gv` (`extract-zip` unvalidated symlink path traversal) was published between two CI runs on the same dependency tree and has no patched version — it covers `extract-zip *`, and it reaches the tree through `@puppeteer/browsers <=2.13.2`, which `puppeteer-core` pins exactly and `whatsapp-web.js` pins exactly in turn, so no `overrides` entry moves it. Forcing `@puppeteer/browsers` 3.x does remove it, but that version replaces `extract-zip` with dependencies that are ESM-only, and 60 Jest suites then fail to load. The advisory is therefore excused by id in `scripts/check-audit.mjs`, with its reachability recorded: the vulnerable path is zip extraction inside `puppeteer browsers install`, which runs once at image-build time on amd64 only, against a version-pinned Chrome for Testing build fetched from Google over HTTPS — nothing in the shipped image extracts a zip through it at runtime. The alternative, dropping the job to `--audit-level=critical`, would have un-gated every future high. An allowlist entry whose advisory has since disappeared fails the job, so the exception cannot outlive its cause. `dashboard/` keeps the plain `npm audit --audit-level=high`.+## [0.18.0] - 2026-08-13### Addeddiff --git a/docs/04-security-design.md b/docs/04-security-design.mdindex c760549ed..8667a6022 100644--- a/docs/04-security-design.md+++ b/docs/04-security-design.md@@ -678,7 +678,7 @@ documented inline.### Security Scanning in CI-> **Aspirational template — not in the repo.** There is no `security.yml`, no Snyk, and no CodeQL workflow today. The actual dependency check is a dedicated `audit` job ("Security audit") in `ci.yml`, running `npm audit --audit-level=high` on push/PR — not on a schedule. It is deliberately its own job rather than a step inside Lint: an advisory published against an unrelated dependency would otherwise abort the job before ESLint, the type-check and the drift gates ever ran. The threshold is `high` rather than `critical` because the `overrides` in `package.json` clear the root tree's existing HIGH advisories, so it now fences regressions. The workflow below is a recommended setup to add if you want scheduled scanning and SAST.+> **Aspirational template — not in the repo.** There is no `security.yml`, no Snyk, and no CodeQL workflow today. The actual dependency check is a dedicated `audit` job ("Security audit") in `ci.yml`, on push/PR — not on a schedule. It is deliberately its own job rather than a step inside Lint: an advisory published against an unrelated dependency would otherwise abort the job before ESLint, the type-check and the drift gates ever ran. It runs `npm run check:audit` over the root tree and `npm audit --audit-level=high` over `dashboard/`. Both fence `high` rather than `critical`, because the `overrides` in `package.json` clear the root tree's existing HIGH advisories, so the threshold fences regressions. `check:audit` applies that threshold per advisory instead of all-or-nothing: an advisory with no patched version can be excused by id in `scripts/check-audit.mjs`, with its reason and its removal condition recorded beside it, rather than dropping the whole job to `critical` — and an allowlist entry whose advisory has since gone fails the job too, so an exception cannot outlive its cause. The dashboard keeps the plain form: it has nothing to excuse and stays the stricter of the two. The workflow below is a recommended setup to add if you want scheduled scanning and SAST.```yaml# .github/workflows/security.ymldiff --git a/docs/10-devops-infrastructure.md b/docs/10-devops-infrastructure.mdindex 64abbed14..7087bddf6 100644--- a/docs/10-devops-infrastructure.md+++ b/docs/10-devops-infrastructure.md@@ -300,16 +300,16 @@ an illustrative design sketch; the chart is the authoritative artifact.SHA image tags to GHCR; `latest` is deliberately not set there and moves only through the separate,boot-smoke-gated release workflow.-| Job | Needs | What it runs |-| --------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `lint` | — | ESLint, `tsc --noEmit -p tsconfig.json` (full program, so spec files are type-checked too), `format:check`, `check:versions`, `check:dockerignore`, `openapi:check` |-| `audit` | — | `npm audit --audit-level=high`, split out of `lint` so a newly published advisory can't abort the code-quality gates |-| `test` | — | `npm test -- --coverage`, `test:scripts`, `test:e2e` (a `redis:7-alpine` service backs the queue-on e2e suite), coverage upload |-| `test-postgres` | — | `npm run build`, then `test:pg-smoke` (migrations + uuid-default) and the Postgres FTS migration spec against a `postgres:16-alpine` service |-| `dashboard` | — | In `dashboard/`: `lint`, `typecheck`, `i18n:check`, `build`, `test:unit` |-| `scripts-smoke` | — | `shellcheck` plus the backup/restore smoke test for `scripts/backup.sh` and `scripts/restore.sh` |-| `build` | lint, audit, test, dashboard, scripts-smoke | `npm run build`, uploads the `dist` artifact |-| `docker` | build, test-postgres | Buildx multi-arch build (`linux/amd64,linux/arm64`) with provenance + SBOM attestations; pushes to `ghcr.io/<owner>/<repo>` on push events (fork PRs build both architectures without publishing) |+| Job | Needs | What it runs |+| --------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| `lint` | — | ESLint, `tsc --noEmit -p tsconfig.json` (full program, so spec files are type-checked too), `format:check`, `check:versions`, `check:dockerignore`, `openapi:check` |+| `audit` | — | `npm run check:audit` (root, high/critical with a per-advisory allowlist) + `npm audit --audit-level=high` (dashboard), split out of `lint` so a newly published advisory can't abort the code-quality gates |+| `test` | — | `npm test -- --coverage`, `test:scripts`, `test:e2e` (a `redis:7-alpine` service backs the queue-on e2e suite), coverage upload |+| `test-postgres` | — | `npm run build`, then `test:pg-smoke` (migrations + uuid-default) and the Postgres FTS migration spec against a `postgres:16-alpine` service |+| `dashboard` | — | In `dashboard/`: `lint`, `typecheck`, `i18n:check`, `build`, `test:unit` |+| `scripts-smoke` | — | `shellcheck` plus the backup/restore smoke test for `scripts/backup.sh` and `scripts/restore.sh` |+| `build` | lint, audit, test, dashboard, scripts-smoke | `npm run build`, uploads the `dist` artifact |+| `docker` | build, test-postgres | Buildx multi-arch build (`linux/amd64,linux/arm64`) with provenance + SBOM attestations; pushes to `ghcr.io/<owner>/<repo>` on push events (fork PRs build both architectures without publishing) |Rollout is left to the operator — the repo has no SSH deploy step, no staging/productionenvironments and no auto-deploy on merge.diff --git a/docs/16-risk-management.md b/docs/16-risk-management.mdindex aa44cdf50..e607734e0 100644--- a/docs/16-risk-management.md+++ b/docs/16-risk-management.md@@ -312,7 +312,7 @@ Dependencies (`whatsapp-web.js`, Puppeteer, NestJS, etc.) may have vulnerabiliti**Mitigation Strategies:**-> **Current state:** the real dependency check is a dedicated `audit` job in `ci.yml` running `npm audit --audit-level=high` (on push / PR — not on a daily schedule); it is deliberately split out of the `Lint` job so a newly published advisory cannot abort the other quality gates. `release.yml` repeats the same `npm audit --audit-level=high` and additionally runs a Trivy image scan (`CRITICAL,HIGH`, `ignore-unfixed`) against an explicit `.trivyignore` before the release tags are promoted. Dependabot PRs cover npm for `/` and `/dashboard` (weekly), GitHub Actions (monthly) and Docker base/compose images (weekly), with version-pinned ignores for `typescript >=7` and `better-sqlite3 >=13`. There is **no** standalone `security.yml` and **no** Snyk integration. The workflow below is a recommended enhancement to add scheduled scanning.+> **Current state:** the real dependency check is a dedicated `audit` job in `ci.yml` running `npm run check:audit` over the root tree and `npm audit --audit-level=high` over `dashboard/` (on push / PR — not on a daily schedule); it is deliberately split out of the `Lint` job so a newly published advisory cannot abort the other quality gates. `check:audit` keeps the `high` threshold but applies it per advisory, so one with no patched version can be excused by id in `scripts/check-audit.mjs` — with its reason and removal condition recorded, and a stale entry failing the job — instead of lowering the bar for everything. `release.yml` repeats both and additionally runs a Trivy image scan (`CRITICAL,HIGH`, `ignore-unfixed`) against an explicit `.trivyignore` before the release tags are promoted. Dependabot PRs cover npm for `/` and `/dashboard` (weekly), GitHub Actions (monthly) and Docker base/compose images (weekly), with version-pinned ignores for `typescript >=7` and `better-sqlite3 >=13`. There is **no** standalone `security.yml` and **no** Snyk integration. The workflow below is a recommended enhancement to add scheduled scanning.```yaml# .github/workflows/security.yml@@ -341,15 +341,15 @@ jobs:**Dependency Management Policy:**-| Action | Frequency |-| ------------------------------------------------------------- | ------------------------ |-| npm audit (`--audit-level=high`, dedicated `audit` job in CI) | Every push / PR |-| Trivy image scan (`CRITICAL,HIGH`, `.trivyignore`) | Every release |-| Snyk scan | Not configured (planned) |-| Dependabot PRs (npm: `/` and `/dashboard`; docker) | Weekly |-| Dependabot PRs (github-actions) | Monthly |-| Major updates | Reviewed manually |-| Security patches | Immediate |+| Action | Frequency |+| ----------------------------------------------------------------------------------------- | ------------------------ |+| npm audit (`high`, per-advisory allowlist via `check:audit`; dedicated `audit` job in CI) | Every push / PR |+| Trivy image scan (`CRITICAL,HIGH`, `.trivyignore`) | Every release |+| Snyk scan | Not configured (planned) |+| Dependabot PRs (npm: `/` and `/dashboard`; docker) | Weekly |+| Dependabot PRs (github-actions) | Monthly |+| Major updates | Reviewed manually |+| Security patches | Immediate |---diff --git a/package.json b/package.jsonindex f523329d3..3576975ce 100644--- a/package.json+++ b/package.json@@ -30,6 +30,7 @@"check:versions": "node scripts/check-doc-versions.mjs","check:dockerignore": "node scripts/check-dockerignore.mjs","check:chart": "node scripts/check-chart-behaviour.mjs",+ "check:audit": "node scripts/check-audit.mjs","check:sdk-routes": "node scripts/check-sdk-routes.mjs","check:sdk-coverage": "node scripts/check-sdk-coverage.mjs","check:sdk-events": "node scripts/check-sdk-events.mjs",@@ -39,7 +40,7 @@"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"","lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix","test": "jest",- "test:scripts": "node --test scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/dockerfile-patchers.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs",+ "test:scripts": "node --test scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/dockerfile-patchers.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs","test:watch": "jest --watch","test:cov": "jest --coverage","test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",diff --git a/scripts/check-audit.mjs b/scripts/check-audit.mjsnew file mode 100644index 000000000..342855976--- /dev/null+++ b/scripts/check-audit.mjs@@ -0,0 +1,142 @@+#!/usr/bin/env node+/**+ * Dependency-audit gate for the ROOT tree, with a per-advisory allowlist.+ *+ * `npm audit --audit-level=high` is all-or-nothing: it fails on any high, and the only lever it+ * offers is lowering the threshold for EVERYTHING. That lever is the wrong one — the audit job+ * exists to fence high-severity regressions, and dropping it to `critical` would silently un-gate+ * every future high to accommodate one advisory that has no fix.+ *+ * So the threshold stays, and an advisory is excused ONE AT A TIME, by id, with its reason recorded+ * next to it. An excused advisory is still visible in `npm audit` output; what changes is only+ * whether CI treats it as a stop.+ *+ * Two rules, and the second is the one that keeps this honest:+ * 1. Any advisory at `high` or `critical` whose id is not allowlisted FAILS.+ * 2. An allowlist entry whose advisory no longer appears ALSO FAILS. A carve-out that outlives+ * its cause is how a gate quietly narrows, so removing it is not left to anyone remembering.+ *+ * Scope: the root tree only. `dashboard/` keeps a plain `npm audit --audit-level=high`, because it+ * has nothing to excuse and should stay the stricter of the two.+ *+ * Run locally: `npm run check:audit`.+ */+import { execFileSync } from 'node:child_process';++/**+ * Advisories CI will not stop on. Every entry states why, and what removes it.+ *+ * Keep this list empty whenever possible. An entry belongs here only when there is no patched+ * version to move to, the reachable path is understood, and the fix is upstream rather than ours.+ */+const ALLOWLIST = [+ {+ id: 'GHSA-jmr9-qjv8-65gv',+ package: 'extract-zip',+ reason:+ 'No patched version exists — the advisory covers extract-zip * and 2.0.1 is the latest publish. ' ++ 'It reaches us only through @puppeteer/browsers <=2.13.2, which puppeteer-core 24.38.0 pins EXACTLY, ' ++ 'and puppeteer 24.38.0 is itself pinned exactly by whatsapp-web.js 1.34.7 — so nothing we can express ' ++ 'in overrides moves it. @puppeteer/browsers 3.x drops extract-zip for modern-tar, but forcing it past ' ++ 'those pins pulls yargs 18 and modern-tar (both type:module) into a CommonJS Jest run and 60 suites ' ++ 'fail to load; that was measured, not assumed. ' ++ 'Reachability: the vulnerable path is zip extraction inside `puppeteer browsers install`, which this ' ++ 'repo calls once, at IMAGE BUILD time, on amd64 only (Dockerfile — arm64 symlinks Debian chromium and ' ++ 'never calls it), against a version-pinned Chrome for Testing build fetched from Google over HTTPS. ' ++ 'Nothing in the shipped image extracts a zip through this path at runtime.',+ removeWhen:+ 'whatsapp-web.js ships a release whose puppeteer pin carries @puppeteer/browsers 3.x. Re-check with ' ++ '`npm view whatsapp-web.js dependencies.puppeteer` then `npm view puppeteer-core@<v> dependencies`.',+ },+];++const BLOCKING = new Set(['high', 'critical']);++/**+ * `npm audit --json` exits non-zero exactly when it found something, so a throw is the normal path+ * and the payload is on stdout either way. Anything that is not parseable JSON is a real failure —+ * a network error or a broken registry — and must not read as "no vulnerabilities".+ */+function runAudit() {+ try {+ return JSON.parse(execFileSync('npm', ['audit', '--json'], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }));+ } catch (err) {+ const stdout = err?.stdout ?? '';+ try {+ return JSON.parse(stdout);+ } catch {+ console.error('check:audit — could not read `npm audit --json` output:');+ console.error(err?.stderr || err?.message || String(err));+ process.exit(1);+ }+ }+}++/**+ * Every distinct advisory in the report, keyed by its GHSA id.+ *+ * npm reports one entry per affected package, but only the directly-vulnerable one carries the+ * advisory OBJECT in `via`; the packages that merely depend on it carry a plain string naming their+ * parent. Collecting the objects is therefore what enumerates advisories rather than symptoms — the+ * extract-zip advisory shows up as five package entries and exactly one advisory.+ */+export function collectAdvisories(report) {+ const found = new Map();+ for (const entry of Object.values(report?.vulnerabilities ?? {})) {+ for (const via of entry.via ?? []) {+ if (typeof via !== 'object' || !via.url) continue;+ const id = via.url.split('/').pop();+ if (!found.has(id)) {+ found.set(id, { id, package: via.name, severity: via.severity, title: via.title, url: via.url });+ }+ }+ }+ return found;+}++/** The gate's verdict, split out so a spec can drive it without shelling out to npm. */+export function evaluate(report, allowlist = ALLOWLIST) {+ const advisories = collectAdvisories(report);+ const allowed = new Set(allowlist.map(a => a.id));+ const errors = [];++ for (const advisory of advisories.values()) {+ if (!BLOCKING.has(advisory.severity)) continue;+ if (allowed.has(advisory.id)) continue;+ errors.push(+ `${advisory.severity.toUpperCase()} ${advisory.id} in ${advisory.package}: ${advisory.title}\n` ++ ` ${advisory.url}\n` ++ ' Fix it, or — only if there is no patched version and the path is understood — add it to\n' ++ ' ALLOWLIST in scripts/check-audit.mjs with a reason and a removeWhen.',+ );+ }++ for (const entry of allowlist) {+ if (advisories.has(entry.id)) continue;+ errors.push(+ `Stale allowlist entry ${entry.id} (${entry.package}): the advisory no longer appears in npm audit.\n` ++ ' Remove it from ALLOWLIST in scripts/check-audit.mjs — an exception that outlives its cause\n' ++ ' narrows this gate for everything that comes after it.',+ );+ }++ return errors;+}++// Guarded so the spec can import the two functions above without running a real audit.+if (import.meta.url === `file://${process.argv[1]}`) {+ const report = runAudit();+ const errors = evaluate(report);++ if (errors.length > 0) {+ console.error('check:audit failed:\n');+ for (const error of errors) console.error(`- ${error}\n`);+ process.exit(1);+ }++ const excused = ALLOWLIST.length;+ console.log(+ `check:audit passed — no unexcused high/critical advisories in the root tree` ++ (excused > 0 ? ` (${excused} allowlisted: ${ALLOWLIST.map(a => a.id).join(', ')})` : ''),+ );+}diff --git a/scripts/check-audit.spec.mjs b/scripts/check-audit.spec.mjsnew file mode 100644index 000000000..152342586--- /dev/null+++ b/scripts/check-audit.spec.mjs@@ -0,0 +1,111 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { collectAdvisories, evaluate } from './check-audit.mjs';++/**+ * The report shape is taken from a real `npm audit --json` run, not invented: one advisory+ * (extract-zip) surfaces as FIVE package entries, and only the directly-vulnerable one carries the+ * advisory object in `via`. The other four name their parent as a plain string. A gate that counted+ * package entries instead of advisories would need four more allowlist ids for one problem.+ */+const advisory = {+ source: 1139346,+ name: 'extract-zip',+ url: 'https://github.com/advisories/GHSA-jmr9-qjv8-65gv',+ severity: 'high',+ title: 'extract-zip unvalidated symlink path traversal',+};++const puppeteerReport = {+ vulnerabilities: {+ 'extract-zip': { name: 'extract-zip', severity: 'high', via: [advisory] },+ '@puppeteer/browsers': { name: '@puppeteer/browsers', severity: 'high', via: ['extract-zip'] },+ puppeteer: { name: 'puppeteer', severity: 'high', via: ['@puppeteer/browsers'] },+ 'puppeteer-core': { name: 'puppeteer-core', severity: 'high', via: ['@puppeteer/browsers'] },+ 'whatsapp-web.js': { name: 'whatsapp-web.js', severity: 'high', via: ['puppeteer'] },+ },+};++const ALLOW = [{ id: 'GHSA-jmr9-qjv8-65gv', package: 'extract-zip', reason: 'x', removeWhen: 'y' }];++test('five package entries for one advisory collapse to a single advisory', () => {+ const found = collectAdvisories(puppeteerReport);+ assert.equal(found.size, 1);+ assert.equal(found.get('GHSA-jmr9-qjv8-65gv').package, 'extract-zip');+});++test('the allowlisted advisory passes', () => {+ assert.deepEqual(evaluate(puppeteerReport, ALLOW), []);+});++// The load-bearing negative. Without this the gate could allowlist everything and still look green.+test('the SAME advisory fails once it is not allowlisted', () => {+ const errors = evaluate(puppeteerReport, []);+ assert.equal(errors.length, 1);+ assert.match(errors[0], /GHSA-jmr9-qjv8-65gv/);+ assert.match(errors[0], /HIGH/);+});++test('a DIFFERENT high advisory still fails while one is allowlisted', () => {+ const report = {+ vulnerabilities: {+ ...puppeteerReport.vulnerabilities,+ tar: {+ name: 'tar',+ severity: 'high',+ via: [{ name: 'tar', url: 'https://github.com/advisories/GHSA-aaaa-bbbb-cccc', severity: 'high', title: 'x' }],+ },+ },+ };+ const errors = evaluate(report, ALLOW);+ assert.equal(errors.length, 1);+ assert.match(errors[0], /GHSA-aaaa-bbbb-cccc/);+});++test('critical is blocking too, not just high', () => {+ const report = {+ vulnerabilities: {+ x: {+ name: 'x',+ severity: 'critical',+ via: [{ name: 'x', url: 'https://github.com/advisories/GHSA-crit-0000-0000', severity: 'critical', title: 'x' }],+ },+ },+ };+ assert.equal(evaluate(report, []).length, 1);+});++test('moderate and low do not block', () => {+ const report = {+ vulnerabilities: {+ x: {+ name: 'x',+ severity: 'moderate',+ via: [{ name: 'x', url: 'https://github.com/advisories/GHSA-mod-0000-0000', severity: 'moderate', title: 'x' }],+ },+ },+ };+ assert.deepEqual(evaluate(report, []), []);+});++/**+ * The rule that stops the carve-out outliving its cause. When whatsapp-web.js ships a puppeteer+ * carrying @puppeteer/browsers 3.x the advisory disappears, and without this the entry would sit+ * there indefinitely, quietly excusing an id nobody re-examines.+ */+test('an allowlist entry whose advisory is gone fails as stale', () => {+ const errors = evaluate({ vulnerabilities: {} }, ALLOW);+ assert.equal(errors.length, 1);+ assert.match(errors[0], /Stale allowlist entry GHSA-jmr9-qjv8-65gv/);+});++test('a clean report with an empty allowlist passes', () => {+ assert.deepEqual(evaluate({ vulnerabilities: {} }, []), []);+});++// npm omits the key entirely when nothing is found; treating that as a crash would fail every+// green build, and treating a crash as "clean" would fail open. It must simply be empty.+test('a report with no vulnerabilities key is clean, not a crash', () => {+ assert.deepEqual(evaluate({}, []), []);+ assert.equal(collectAdvisories(undefined).size, 0);+});