diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 97aaf77..a3721bb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,9 @@ version: 2 updates: - # Root npm project. `/workers/widgets` is intentionally omitted until that worker exists. + # Root npm project. `/workers/widgets` is still omitted, but the reason has changed: + # the worker exists now, it is just deliberately dependency-free (no package.json, the + # YouTube RSS is hand-parsed), so there is no manifest for Dependabot to read. Add an + # entry here the day that worker gains a package.json. - package-ecosystem: npm directory: "/" schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 592c437..5266a03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,16 +21,25 @@ concurrency: jobs: build: runs-on: ubuntu-latest + # Job-level too, so a second job added later can't silently inherit something wider. + permissions: + contents: read steps: - - uses: actions/checkout@v7 + # Actions are pinned to commit SHAs, not tags: a tag is mutable, so `@v7` would + # execute whatever that tag points at on the day CI runs. Dependabot's + # github-actions ecosystem updates the pins and keeps the version comment in sync. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 # check-exif diffs changed images against the base ref - - uses: actions/setup-node@v7 + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .nvmrc cache: npm + # Lifecycle scripts run only for the packages allow-listed in package.json + # #allowScripts; .npmrc sets strict-allow-scripts so anything unreviewed is a + # hard install failure rather than a warning (docs 06 §6, anti-worm). - name: Install run: npm ci diff --git a/.github/workflows/osv-scanner.yml b/.github/workflows/osv-scanner.yml new file mode 100644 index 0000000..bbb9102 --- /dev/null +++ b/.github/workflows/osv-scanner.yml @@ -0,0 +1,40 @@ +name: OSV scan + +# docs 06 §6 and 08 §2 both call for a weekly dependency scan; this is it. +# It complements the per-PR `npm audit --omit=dev --audit-level=high` gate in ci.yml: +# audit only sees the production tree and only fails on high+, while OSV covers the +# whole lockfile (devDependencies included) against the full OSV database. +on: + schedule: + # Mondays 03:17 UTC — off the hour, where scheduled-runner contention is lowest. + - cron: "17 3 * * 1" + workflow_dispatch: + # Re-run when the dependency graph itself changes, so a bad bump is caught on the PR + # rather than up to a week later. + pull_request: + paths: ["package-lock.json", "osv-scanner.toml"] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + scan: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + # The scanner runs directly rather than via google/osv-scanner-action's reusable + # SARIF workflow: SARIF upload needs `security-events: write` plus code scanning, + # which is not available on this plan. A non-zero exit failing the run is the + # alert. Once the repo is public, code scanning becomes free and this can be + # switched to the reusable workflow for findings in the Security tab. + - uses: google/osv-scanner-action/osv-scanner-action@8deb546fdb875b9996d27d4950be7312dac076a1 # v2.5.0 + with: + scan-args: |- + --lockfile=package-lock.json diff --git a/.npmrc b/.npmrc index 1812199..359b2f2 100644 --- a/.npmrc +++ b/.npmrc @@ -1,4 +1,11 @@ -# Supply-chain hardening (ignore-scripts) is applied in CI only — see docs 06 §1.6. -# Locally we leave install scripts enabled so `sharp` can set up its binaries -# for build-time image processing (astro imageService: 'compile'). +# Supply-chain hardening (docs 06 §6). npm >= 11 resolves lifecycle scripts against +# package.json#allowScripts; `strict-allow-scripts` turns "package X has an install +# script you haven't reviewed" from a warning into a failed install. A dependency that +# suddenly grows a postinstall — the Shai-Hulud worm shape — stops the build instead of +# executing. Review it, then `npm approve-scripts ` to add it to the allowlist. +# +# The previous note here claimed CI applied `ignore-scripts` and that `sharp` needed +# scripts. Both were wrong: CI never set it, and sharp@0.35 ships prebuilt @img/sharp-* +# binaries with no install script at all. fund=false +strict-allow-scripts=true diff --git a/osv-scanner.toml b/osv-scanner.toml new file mode 100644 index 0000000..0654443 --- /dev/null +++ b/osv-scanner.toml @@ -0,0 +1,19 @@ +# Suppressions for the weekly OSV scan (.github/workflows/osv-scanner.yml). +# +# Rules for adding an entry: +# - every entry carries `untilDate`, so a suppression expires and gets re-argued +# instead of quietly becoming permanent; +# - `reason` must say why it is not exploitable HERE, not merely that it is annoying; +# - if a fix ships, delete the entry rather than extending the date. + +[[IgnoredVulns]] +id = "GHSA-5p4m-2wfm-xmqj" +untilDate = 2026-11-10T00:00:00Z +reason = """ +js-yaml 3.x quadratic CPU in !!omap resolution, reached via gray-matter@4 -> js-yaml@3.15.0. +There is no patched 3.x — the fix was not backported — and gray-matter needs the v3 API +(safeLoad), so the js-yaml override in package.json is deliberately scoped to ^4. +Not exploitable here: gray-matter is a devDependency used only by scripts/gen-og.mjs at +build time, and the only YAML it ever parses is our own committed content frontmatter. +No untrusted YAML reaches it. Revisit if gray-matter is replaced or ships a v4 engine. +""" diff --git a/package.json b/package.json index 96b173b..d49fdb0 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,12 @@ "engines": { "node": ">=24" }, + "allowScripts": { + "esbuild": true, + "workerd": true, + "lefthook": true, + "fsevents": true + }, "scripts": { "dev": "astro dev", "build": "astro build && node scripts/gen-og.mjs && pagefind --site dist/client && node scripts/check-csp-hashes.mjs",