name: Dependency Audit on: push: branches: ["main"] pull_request: schedule: - cron: "0 6 * * 1" # weekly Monday 06:00 UTC permissions: contents: read concurrency: group: dependency-audit-${{ github.ref }} cancel-in-progress: true jobs: audit: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 1 - name: Setup pnpm uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 with: version: 11.19.0 run_install: false - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: "22" # No dependency download happens in this workflow (pnpm audit reads # the lockfile), so the pnpm cache path may not exist and the # cache-save post step would fail path validation. - name: Enable Corepack run: | corepack enable corepack prepare pnpm@11.19.0 --activate - name: Lockfile must be committed run: | test -f pnpm-lock.yaml || { echo "FAIL: pnpm-lock.yaml is missing"; exit 1; } git ls-files | grep -qx "pnpm-lock.yaml" || { echo "FAIL: pnpm-lock.yaml is not tracked"; exit 1; } # pnpm-lock.yaml is the ONLY manifest in this repo. A second lockfile # (package-lock.json) used to be committed alongside it, drifted out of # sync, and made Dependabot report every advisory twice — once per # manifest. Keep it out. Run `pnpm install`, never `npm install`. if [ -e package-lock.json ] || [ -e yarn.lock ]; then echo "FAIL: a second lockfile is present. This repo is pnpm-only." exit 1 fi echo "Lockfile OK" - name: No floating version ranges in production deps run: | if node -e "const p=require('./package.json'); const all={...p.dependencies}; const bad=Object.entries(all).filter(([,v])=>/[\^~]/.test(v)); if(bad.length){console.error('Floating ranges:',bad.map(([k,v])=>k+'@'+v).join(', '));process.exit(1)}"; then echo "Pinned versions OK" else echo "FAIL: floating (^/~) ranges in dependencies" exit 1 fi - name: Manifests parse (no duplicated keys, no merge-conflict markers) run: | # `pnpm install` parses pnpm-workspace.yaml before it resolves a single # dependency and refuses duplicated mapping keys: # [ERROR] duplicated mapping key (21:3) -> exit 1 # Vercel installs before it builds, so one duplicated key takes the # deploy down before any application code compiles. That happened once # already: a branch added a `source-map-js` override, main added the # same override with different comments, git auto-merged both blocks # (the text differed, the meaning did not), and the Vercel build died # two seconds into `pnpm install`. This step fails in one second with # the offending key and line instead of three minutes into resolution. # Duplicated package.json keys are checked too: JSON.parse silently # keeps the last one, so no other gate in this repo would see it. node scripts/check-manifests.mjs - name: Known CVE overrides present (js-yaml, source-map-js, brace-expansion, sharp, postcss-selector-parser, braces waiver) run: | grep -q "js-yaml: 4.3.2" pnpm-workspace.yaml || { echo "FAIL: js-yaml 4.3.2 override missing"; exit 1; } grep -q "brace-expansion@1: 1.1.21" pnpm-workspace.yaml || { echo "FAIL: brace-expansion 1.x override missing"; exit 1; } grep -q "brace-expansion@5: 5.0.12" pnpm-workspace.yaml || { echo "FAIL: brace-expansion 5.x override missing"; exit 1; } # GHSA-68fv-2mgg-jv7q — source-map-js event-loop DoS. Several independent # postcss copies exist in the tree (next pins postcss@8.5.23 internally), # so the direct `postcss` bump does not cover the whole graph. grep -q "source-map-js: 1.2.2" pnpm-workspace.yaml || { echo "FAIL: source-map-js 1.2.2 override missing"; exit 1; } # GHSA-wq5f-xc86-pv6w — sharp <0.35.5 vulnerable librsvg (CVE-2026-96889). grep -q "sharp: 0.35.5" pnpm-workspace.yaml || { echo "FAIL: sharp 0.35.5 override missing"; exit 1; } # GHSA-rj75-hqrm-r3gf (CVE-2026-104844) — postcss-selector-parser CPU # exhaustion. No patched 6.x is published, so 7.x is the only version fix. # Verified byte-identical Tailwind CSS output vs 6.1.4 in this app. grep -q "postcss-selector-parser: 7.1.6" pnpm-workspace.yaml || { echo "FAIL: postcss-selector-parser 7.1.6 override missing"; exit 1; } # GHSA-cjq9-62q9-8jv4 & 5 related Next.js advisories — all patched in 16.3.8. node -e "const v=require('./package.json').dependencies.next; if(v!=='16.3.8'){console.error('FAIL: next is '+v+', expected 16.3.8');process.exit(1)}" # TEMPORARY WAIVER (GHSA-vfj7-8cjw-p6xm, braces DoS): no patched # release is published on npm yet (latest is 3.0.3), so a version # override is impossible today. The CVE is waived via # pnpm-workspace.yaml audit.ignore instead. When braces # 3.0.4+ ships, replace the waiver with a `braces: 3.0.4` # override and drop this grep. grep -q "GHSA-vfj7-8cjw-p6xm" pnpm-workspace.yaml || { echo "FAIL: braces CVE waiver missing"; exit 1; } grep -q '"packageManager": "pnpm@' package.json || { echo "FAIL: packageManager pin missing"; exit 1; } echo "Overrides OK" - name: pnpm audit must stay clean (full tree, high+) run: pnpm audit --audit-level=high - name: pnpm audit must stay clean (production tree) run: pnpm audit --prod --audit-level=low