chore(ci): pin actions to SHAs, add weekly OSV scan, enforce install-script allowlist

Three supply-chain gaps, two of which the repo already claimed to have closed.

1. Actions were pinned to floating tags (`actions/checkout@v7`). A tag is mutable,
   so CI executed whatever that tag pointed at on the day it ran. Now pinned to
   commit SHAs with the version in a trailing comment; the existing
   github-actions Dependabot ecosystem keeps both in sync.

2. Weekly OSV scan (.github/workflows/osv-scanner.yml). docs 06 §6 and 08 §2 both
   require one and none existed. It complements the per-PR audit gate: `npm audit
   --omit=dev --audit-level=high` only sees the production tree and only fails on
   high+, while OSV covers the whole lockfile against the full database. Also runs
   on PRs that touch package-lock.json so a bad bump is caught on the PR instead of
   up to a week later.

   It runs the scanner directly rather than the reusable SARIF workflow, because
   SARIF upload needs `security-events: write` plus code scanning, which this plan
   does not have. A non-zero exit failing the run is the alert. Switch to the
   reusable workflow once the repo is public and code scanning is free.

   osv-scanner.toml carries one suppression: gray-matter -> js-yaml@3.15.0
   (GHSA-5p4m-2wfm-xmqj), which has no patched 3.x and only ever parses our own
   committed frontmatter at build time. It has an `untilDate` so it expires and
   gets re-argued rather than becoming permanent.

3. Install-script hardening. `.npmrc` asserted "ignore-scripts is applied in CI"
   and that sharp needed scripts. Both were false: ci.yml never set it, and
   sharp@0.35 ships prebuilt @img/sharp-* binaries with no install script at all.
   Replaced with npm 11's allowlist model, which is what docs 06 §6 actually asks
   for: package.json#allowScripts names the four packages that legitimately have
   install scripts (esbuild, workerd, lefthook, fsevents) and .npmrc sets
   strict-allow-scripts so anything unreviewed is a hard failure.

   Verified in a clean directory: with strict on and esbuild NOT allow-listed,
   `npm install` exits 1 with ESTRICTALLOWSCRIPTS; with it allow-listed, it
   succeeds. A dependency that suddenly grows a postinstall now stops the build
   instead of executing it.

Also: job-level `permissions:` on the build job, and dependabot.yml's stale note
about /workers/widgets corrected — the worker exists now; it is skipped because it
is deliberately dependency-free and has no manifest to read.

Verified: prettier, eslint, astro check (0 errors), knip, build + CSP guard, audit
gate all green; `npm ci --dry-run` confirms lockfile and package.json stay in sync.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 5 committed 2026-08-10 00:41:04 +07:00
1 parent 206998a20f
commit 32f1272377
6 files changed
+90 -6

No files matched your search

+4 -1
View File
@@ -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:
+11 -2
View File
@@ -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
+40
View File
@@ -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
+10 -3
View File
@@ -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 <pkg>` 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
+19
View File
@@ -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.
"""
+6
View File
@@ -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",