From b6cc46b6cfbc57bebaad86437f3ef022658b6ff3 Mon Sep 17 00:00:00 2001 From: William Frank Monroy Mamani Date: Mon, 30 Nov 2026 00:30:39 -0600 Subject: [PATCH 1/3] fix(release): state which jobs block egress, check the package's own prepare scripts, measure install size - standalone.yml: the macOS build job runs Harden-Runner in audit mode (GitHub's macOS and Windows runners support no block mode); smoke blocks on Linux and audits elsewhere. SECURITY.md, RELEASING.md and the release.yml header name the jobs that block. - pack-check checks the published package as a project, the way the Homebrew formula's `npm ci` installs it: prepublish, preprepare, prepare, postprepare and dependencies too. publishedManifest drops the scripts pnpm pack leaves out. - SECURITY.md and the install pages: npm ignores the shrinkwrap for a downloaded tarball. - bench/install-size.mjs and its first result (turno-cli 0.1.1, 0.2.0, 0.6.3); the 0.2.0 release page cites it. --- .github/workflows/release.yml | 4 +- .github/workflows/standalone.yml | 21 ++- SECURITY.md | 16 +- .../docs/(docs)/get-started/install.es.mdx | 2 +- .../docs/(docs)/get-started/install.mdx | 2 +- apps/docs/content/releases/cli/0-2-0.mdx | 2 +- bench/install-size.mjs | 149 ++++++++++++++++++ .../2026-11-30-m3-16gb-install-size.json | 51 ++++++ docs/RELEASING.md | 13 +- scripts/pack-check.mjs | 3 +- scripts/shrinkwrap.mjs | 27 +++- scripts/shrinkwrap.test.mjs | 22 +++ 12 files changed, 288 insertions(+), 24 deletions(-) create mode 100644 bench/install-size.mjs create mode 100644 bench/results/2026-11-30-m3-16gb-install-size.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4ea7e90..eae73ae3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,8 @@ name: release # (prepack writes its npm-shrinkwrap.json; pack:check verifies it and that nothing # in the published tree has an install script), writes an SBOM per package, # uploads them as an artifact. No id-token, no secrets. -# Every job runs Harden-Runner in block mode with its own allow list. +# version, build, publish and tag run on Linux with Harden-Runner in block mode, each with +# its own allow list. # publish downloads the tarballs, attests them and publishes with npm trusted publishing. # No checkout, no install, no cache, runs in the protected "npm" environment, # with Harden-Runner blocking every host outside its allow list (as in tag). @@ -16,6 +17,7 @@ name: release # standalone after a turno-browser release, the standalone executables (standalone.yml), # built from the tarball that was published and uploaded to its GitHub release. It # runs after npm has the version, so a failure here never holds back the npm release. +# Its build job runs on macOS, where Harden-Runner can only audit (see standalone.yml). on: push: branches: [main] diff --git a/.github/workflows/standalone.yml b/.github/workflows/standalone.yml index 22fb2db0..07663ced 100644 --- a/.github/workflows/standalone.yml +++ b/.github/workflows/standalone.yml @@ -4,11 +4,14 @@ name: standalone # npm (scripts/standalone-build.mjs). Three jobs, so the one that can write never runs project code: # build on macOS (the macOS executables are signed ad hoc there), every target from the # same packed package and the pinned Node.js; uploads the archives and SHA256SUMS -# as an artifact. No id-token, no secrets. +# as an artifact. No id-token, no secrets. Harden-Runner only audits it: GitHub's +# macOS runners do not support block mode. # smoke on each platform: the executable answers --version and an MCP initialize -# (scripts/standalone-smoke.mjs). Windows is experimental and may fail. +# (scripts/standalone-smoke.mjs). Windows is experimental and may fail. Harden-Runner +# blocks on Linux and audits on macOS and Windows. # release attests the archives and uploads them with SHA256SUMS to the GitHub release -# turno-browser@. Skipped in a dry run, which keeps them in the run's artifact. +# turno-browser@, with Harden-Runner blocking every host outside its allow +# list. Skipped in a dry run, which keeps them in the run's artifact. # Signing: the macOS executables are signed ad hoc and the Windows one is not signed, so # Gatekeeper and SmartScreen warn on a browser download (the docs say what to do). Developer ID # signing and notarization, or Authenticode, would sign each executable in the build job before @@ -61,6 +64,14 @@ jobs: outputs: version: ${{ steps.version.outputs.version }} steps: + # Audit mode only: on GitHub's macOS runners Harden-Runner can log connections but not + # block them (block mode is Linux only). The job holds no write credential: contents: read, + # no id-token, no secrets. Its downloads are checked instead: the Node.js archives + # (nodejs.org) against the SHA-256 in standalone-node.json, the packages (registry.npmjs.org) + # against the integrity in pnpm-lock.yaml or npm-shrinkwrap.json. + - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -121,10 +132,10 @@ jobs: permissions: contents: read # check out the smoke script steps: + # Block mode on Linux; on GitHub's macOS and Windows runners Harden-Runner can only audit. - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 - if: runner.os == 'Linux' with: - egress-policy: block + egress-policy: ${{ runner.os == 'Linux' && 'block' || 'audit' }} allowed-endpoints: > github.com:443 api.github.com:443 diff --git a/SECURITY.md b/SECURITY.md index 14de4be8..b15fb790 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -233,10 +233,18 @@ laptop, with npm trusted publishing: there is no long-lived npm token. One job r and packs the tarballs; a separate job, in a protected environment that a maintainer approves, attests and publishes those same tarballs without checking out the repository, installing anything or using a cache, so no project or dependency code runs where the publishing -credential lives. Every release job can reach only the hosts on its allow list. `turno-cli` -and `turno-browser` ship an `npm-shrinkwrap.json`, so `npm install --global` installs the -exact dependency tree that CI tested, and nothing in it runs an install script. Each GitHub -release carries a CycloneDX SBOM. Details: [docs/RELEASING.md](docs/RELEASING.md). +credential lives. The release jobs on Linux (the version pull request, tests and packing, +publishing, tagging, the upload of the standalone archives) can reach only the hosts on their +allow list (Harden-Runner in block mode). The job that builds the standalone turno-browser +executables runs on macOS, where Harden-Runner can only log connections, not block them: it +holds no write credential and checks what it downloads (Node.js against a pinned SHA-256, +packages against their lockfile integrity), and a separate Linux job with an allow list attests +and uploads its archives. `turno-cli` and `turno-browser` ship an `npm-shrinkwrap.json`, so +`npm install --global` from the registry and the Homebrew formula (`npm ci` in the package +folder) install the exact dependency tree that CI tested, and nothing in it runs an install +script. Installing a downloaded tarball (`npm install --global ./turno-cli-.tgz`) does +not: npm then ignores the shrinkwrap and resolves the dependencies again. Each GitHub release +carries a CycloneDX SBOM. Details: [docs/RELEASING.md](docs/RELEASING.md). To verify what you installed: diff --git a/apps/docs/content/docs/(docs)/get-started/install.es.mdx b/apps/docs/content/docs/(docs)/get-started/install.es.mdx index 40e47165..1836d15d 100644 --- a/apps/docs/content/docs/(docs)/get-started/install.es.mdx +++ b/apps/docs/content/docs/(docs)/get-started/install.es.mdx @@ -26,7 +26,7 @@ turno version `turno upgrade` actualiza turno después con la misma herramienta que lo instaló. CI instala la versión empaquetada con cada una de estas en macOS y Linux y la ejecuta. - El paquete no ejecuta scripts de instalación, así que pnpm y bun, que bloquean los scripts de las dependencias por defecto, no piden aprobación. -- npm y Homebrew instalan exactamente las versiones de dependencias que se probaron, desde el `npm-shrinkwrap.json` del paquete. pnpm, bun y yarn no leen ese archivo: instalan las mismas dependencias directas (fijadas a versiones exactas) y resuelven por su cuenta las dependencias de esas. +- npm y Homebrew instalan exactamente las versiones de dependencias que se probaron, desde el `npm-shrinkwrap.json` del paquete (npm cuando instala desde el registro; la fórmula de Homebrew corre `npm ci` sobre el paquete). npm ignora ese archivo si instalas un `.tgz` descargado. pnpm, bun y yarn no leen ese archivo: instalan las mismas dependencias directas (fijadas a versiones exactas) y resuelven por su cuenta las dependencias de esas. - pnpm 11 y posteriores esperan un día antes de instalar una versión nueva (`minimumReleaseAge`), así que una versión llega a pnpm un día después que a npm. - yarn quiere decir yarn 1 (classic). yarn 2 y posteriores no instalan global: ahí usa npm, pnpm o bun. diff --git a/apps/docs/content/docs/(docs)/get-started/install.mdx b/apps/docs/content/docs/(docs)/get-started/install.mdx index bfacb593..095b3274 100644 --- a/apps/docs/content/docs/(docs)/get-started/install.mdx +++ b/apps/docs/content/docs/(docs)/get-started/install.mdx @@ -26,7 +26,7 @@ turno version `turno upgrade` later updates turno with the same tool that installed it. CI installs the packed release with each of these on macOS and Linux and runs it. - The package runs no install scripts, so pnpm and bun, which block dependencies' scripts by default, need no approval. -- npm and Homebrew install exactly the dependency versions that were tested, from the package's `npm-shrinkwrap.json`. pnpm, bun and yarn do not read that file: they install the same direct dependencies (pinned to exact versions) and resolve the dependencies of those themselves. +- npm and Homebrew install exactly the dependency versions that were tested, from the package's `npm-shrinkwrap.json` (npm when it installs from the registry; the Homebrew formula runs `npm ci` on the package). npm ignores that file when you install a downloaded `.tgz` instead. pnpm, bun and yarn do not read that file: they install the same direct dependencies (pinned to exact versions) and resolve the dependencies of those themselves. - pnpm 11 and later wait a day before they install a new release (`minimumReleaseAge`), so a release reaches pnpm a day after npm. - yarn means yarn 1 (classic). yarn 2 and later have no global installs: use npm, pnpm or bun there. diff --git a/apps/docs/content/releases/cli/0-2-0.mdx b/apps/docs/content/releases/cli/0-2-0.mdx index 9b7d66f0..7c25bb29 100644 --- a/apps/docs/content/releases/cli/0-2-0.mdx +++ b/apps/docs/content/releases/cli/0-2-0.mdx @@ -140,7 +140,7 @@ turno mcp savings - **Secrets**: `turno secret set` no longer passes the value as a command argument. On Linux, `turno secret` and `keychain:` references use the Secret Service through `secret-tool`. - **Private files**: turno's folders are created 0700 and the files it writes 0600. Backups are private and pruned after 30 days, always keeping the newest 10. - **`turno open`**: accepts only http(s) and mailto links, and works on Linux. -- **A lighter, locked install**: `turno-cli` no longer pulls in `turno-browser` and `turno-fonts` (about 52 MB down to 27 MB), and both packages ship an `npm-shrinkwrap.json`. No package in either tree runs an install script. +- **A lighter, locked install**: `turno-cli` no longer pulls in `turno-browser` and `turno-fonts` (a clean global install takes 27.7 MiB on disk, down from 51.4 MiB for 0.1.1; [measured](https://github.com/wimo-dev/turno/blob/main/bench/results/2026-11-30-m3-16gb-install-size.json)), and both packages ship an `npm-shrinkwrap.json`. No package in either tree runs an install script. ## Fixes diff --git a/bench/install-size.mjs b/bench/install-size.mjs new file mode 100644 index 00000000..fe7d674f --- /dev/null +++ b/bench/install-size.mjs @@ -0,0 +1,149 @@ +#!/usr/bin/env node +// Measures what `npm install --global turno-cli@` puts on disk. +// +// node bench/install-size.mjs [--versions 0.1.1,0.2.0,0.6.3] [--out bench/results/.json] +// +// Each version goes into its own empty prefix with an empty npm cache, a throwaway HOME and +// empty user and global npmrc files, so nothing from your own setup or an earlier run counts. +// Install scripts are not run (--ignore-scripts): the packages since 0.2.0 have none, and a +// measurement should not run third-party code. A version without an npm-shrinkwrap.json (before +// 0.2.0) resolves its dependency ranges to what the registry has today. +// Size is the sum of the file sizes under lib/node_modules (MiB, and MB in parentheses) and the +// disk usage `du -sk` reports for it; packages are the folders with a package.json under it, +// turno-cli included. + +import { execFileSync } from "node:child_process"; +import { lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { cpus, platform, release, tmpdir, totalmem } from "node:os"; +import { join } from "node:path"; +import { parseArgs } from "node:util"; + +const { values } = parseArgs({ + options: { + versions: { type: "string", default: "0.1.1,0.2.0,0.6.3" }, + out: { type: "string" }, + }, +}); + +const MIB = 1024 * 1024; +const startedAt = new Date(); +const npmVersion = execFileSync("npm", ["--version"], { encoding: "utf8" }).trim(); + +function osName() { + if (platform() !== "darwin") return `${platform()} ${release()}`; + return `macOS ${execFileSync("sw_vers", ["-productVersion"], { encoding: "utf8" }).trim()}`; +} + +function apparentBytes(dir) { + let total = 0; + for (const name of readdirSync(dir)) { + const p = join(dir, name); + const st = lstatSync(p); + total += st.isDirectory() ? apparentBytes(p) : st.size; + } + return total; +} + +function measure(version) { + const work = mkdtempSync(join(tmpdir(), "turno-install-size-")); + try { + for (const d of ["home", "cache", "prefix"]) mkdirSync(join(work, d)); + writeFileSync(join(work, "user.npmrc"), ""); + writeFileSync(join(work, "global.npmrc"), ""); + const env = { + PATH: process.env.PATH, + HOME: join(work, "home"), + npm_config_cache: join(work, "cache"), + npm_config_userconfig: join(work, "user.npmrc"), + npm_config_globalconfig: join(work, "global.npmrc"), + npm_config_update_notifier: "false", + }; + const args = [ + "install", + "--global", + "--prefix", + join(work, "prefix"), + "--ignore-scripts", + "--no-audit", + "--no-fund", + ]; + const began = Date.now(); + const out = execFileSync("npm", [...args, `turno-cli@${version}`], { env, encoding: "utf8" }); + const seconds = (Date.now() - began) / 1000; + const modules = join(work, "prefix", "lib", "node_modules"); + const packages = packageDirs(modules); + const installed = JSON.parse(readFileSync(join(modules, "turno-cli", "package.json"), "utf8")).version; + if (installed !== version) throw new Error(`asked for ${version}, npm installed ${installed}`); + const bytes = apparentBytes(modules); + const diskKiB = Number(execFileSync("du", ["-sk", modules], { encoding: "utf8" }).split(/\s/)[0]); + return { + version, + shrinkwrap: hasShrinkwrap(join(modules, "turno-cli")), + packages, + npmAdded: Number(/added (\d+) package/.exec(out)?.[1] ?? Number.NaN), + bytes, + mib: Math.round((bytes / MIB) * 10) / 10, + mb: Math.round((bytes / 1e6) * 10) / 10, + diskMiB: Math.round((diskKiB / 1024) * 10) / 10, + seconds: Math.round(seconds * 10) / 10, + }; + } finally { + rmSync(work, { recursive: true, force: true }); + } +} + +/** Folders with a package.json under a node_modules tree, nested ones included. */ +function packageDirs(modules) { + let count = 0; + for (const name of readdirSync(modules)) { + if (name.startsWith(".")) continue; + const dirs = name.startsWith("@") + ? readdirSync(join(modules, name)).map((n) => join(modules, name, n)) + : [join(modules, name)]; + for (const dir of dirs) { + if (!lstatSync(dir).isDirectory()) continue; + try { + lstatSync(join(dir, "package.json")); + count++; + } catch {} + try { + count += packageDirs(join(dir, "node_modules")); + } catch {} + } + } + return count; +} + +function hasShrinkwrap(dir) { + try { + lstatSync(join(dir, "npm-shrinkwrap.json")); + return true; + } catch { + return false; + } +} + +const rows = values.versions.split(",").map((v) => measure(v.trim())); +const result = { + version: 1, + kind: "turno-cli-install-size", + startedAt: startedAt.toISOString(), + startedAtMonterrey: startedAt.toLocaleString("sv-SE", { timeZone: "America/Monterrey" }), + finishedAt: new Date().toISOString(), + command: `node bench/install-size.mjs --versions ${values.versions}`, + install: "npm install --global --prefix --ignore-scripts --no-audit --no-fund turno-cli@", + machine: { + cpu: cpus()[0]?.model, + memoryGiB: Math.round(totalmem() / 1024 ** 3), + os: osName(), + }, + node: process.version, + npm: npmVersion, + rows, +}; + +for (const r of rows) + console.log( + `turno-cli ${r.version}: ${r.mib} MiB (${r.mb} MB), ${r.diskMiB} MiB on disk, ${r.packages} packages${r.shrinkwrap ? ", shrinkwrap" : ""}`, + ); +if (values.out) writeFileSync(values.out, `${JSON.stringify(result, null, 2)}\n`); diff --git a/bench/results/2026-11-30-m3-16gb-install-size.json b/bench/results/2026-11-30-m3-16gb-install-size.json new file mode 100644 index 00000000..8c95732d --- /dev/null +++ b/bench/results/2026-11-30-m3-16gb-install-size.json @@ -0,0 +1,51 @@ +{ + "version": 1, + "kind": "turno-cli-install-size", + "startedAt": "2026-11-30T06:20:14.535Z", + "startedAtMonterrey": "2026-11-30 00:20:14", + "finishedAt": "2026-11-30T06:20:40.327Z", + "command": "node bench/install-size.mjs --versions 0.1.1,0.2.0,0.6.3", + "install": "npm install --global --prefix --ignore-scripts --no-audit --no-fund turno-cli@", + "machine": { + "cpu": "Apple M3", + "memoryGiB": 16, + "os": "macOS 27.2.1" + }, + "node": "v26.13.0", + "npm": "11.20.0", + "rows": [ + { + "version": "0.1.1", + "shrinkwrap": false, + "packages": 100, + "npmAdded": 100, + "bytes": 43109463, + "mib": 41.1, + "mb": 43.1, + "diskMiB": 51.4, + "seconds": 7.8 + }, + { + "version": "0.2.0", + "shrinkwrap": true, + "packages": 97, + "npmAdded": 97, + "bytes": 18541668, + "mib": 17.7, + "mb": 18.5, + "diskMiB": 27.7, + "seconds": 9.6 + }, + { + "version": "0.6.3", + "shrinkwrap": true, + "packages": 98, + "npmAdded": 98, + "bytes": 18851108, + "mib": 18, + "mb": 18.9, + "diskMiB": 28.2, + "seconds": 5 + } + ] +} diff --git a/docs/RELEASING.md b/docs/RELEASING.md index e654660f..74c874fd 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -164,8 +164,11 @@ Releases after that need nothing by hand. The same steps apply to any other new - Workflows: `permissions: {}` at the top and the minimum per job, every action pinned to a full commit SHA (Dependabot keeps them current), `persist-credentials: false`, no `pull_request_target`, no cache in the release workflow. Harden-Runner blocks every host - outside each release job's allow list and audits the other workflows. When a - release job fails with a blocked connection, see "Egress allow lists" below. + outside the allow list of each release job on Linux (the four jobs of `release.yml`, the + Linux smoke test and the upload of `standalone.yml`) and audits everything else: the other + workflows, and the macOS and Windows jobs of `standalone.yml`, because GitHub's macOS and + Windows runners support only its audit mode. When a release job fails with a blocked + connection, see "Egress allow lists" below. `zizmor.yml` lints the workflows on every change to `.github/`; `scorecard.yml` runs the OpenSSF Scorecard weekly. - Dependencies: pnpm waits three days before installing a newly published version @@ -180,9 +183,9 @@ Releases after that need nothing by hand. The same steps apply to any other new ## Egress allow lists -Each job of `release.yml` lists the hosts it may reach under `allowed-endpoints`. A host -outside the list is blocked, and the step that needed it fails (a timeout or `ECONNREFUSED`, -often a pnpm `ERR_PNPM_META_FETCH_FAIL`). To check a run, open the "View security insights" +Each job of `release.yml` and each Linux job of `standalone.yml` lists the hosts it may reach +under `allowed-endpoints`. A host outside the list is blocked, and the step that needed it +fails (a timeout or `ECONNREFUSED`, often a pnpm `ERR_PNPM_META_FETCH_FAIL`). To check a run, open the "View security insights" link that Harden-Runner prints in the job log: its Network events tab lists every connection, blocked ones marked. To add a host, append `host:443` to that job's list in a pull request. To go back to observing only, change that job's `egress-policy: block` to `audit`; the list can diff --git a/scripts/pack-check.mjs b/scripts/pack-check.mjs index 3aa0c11d..ba07cf75 100644 --- a/scripts/pack-check.mjs +++ b/scripts/pack-check.mjs @@ -88,7 +88,8 @@ function checkTree(cwd, source, packed) { // What pnpm publishes: workspace:* dependencies (turno-core) become exact versions. const pkg = publishedManifest(source, workspaceVersions(cwd)); for (const d of inexactDependencies(pkg)) fail(pkg.name, `${d} is not an exact version`); - for (const s of installScripts(pkg, cwd)) fail(pkg.name, `runs an install script (${s})`); + // As a project: the Homebrew formula runs `npm ci` in the package folder. + for (const s of installScripts(pkg, cwd, { project: true })) fail(pkg.name, `runs an install script (${s})`); const hasDeps = Object.keys({ ...pkg.dependencies, ...pkg.optionalDependencies }).length > 0; if (!hasDeps) return; if (!packed.has(FILE)) return fail(pkg.name, `${FILE} is not in the tarball (add it to "files")`); diff --git a/scripts/shrinkwrap.mjs b/scripts/shrinkwrap.mjs index bf3d7bd4..d612d0f9 100644 --- a/scripts/shrinkwrap.mjs +++ b/scripts/shrinkwrap.mjs @@ -14,7 +14,18 @@ import { fileURLToPath } from "node:url"; const REGISTRY = "https://registry.npmjs.org"; export const FILE = "npm-shrinkwrap.json"; -const INSTALL_SCRIPTS = ["preinstall", "install", "postinstall"]; +// The lifecycle scripts npm runs for a package depend on how it arrives (npm docs, "Life Cycle +// Operation Order" and `npm install-scripts`; checked with npm 11.20): +// a dependency from the registry or a tarball preinstall, install, postinstall +// a dependency from git or a folder also prepare (never in a published tree: every +// entry resolves to a registry tarball) +// the project itself, by `npm ci` or a bare also prepublish, preprepare, prepare, +// `npm install` in its folder (Homebrew) postprepare and dependencies +// prepack and postpack run only for `npm pack` and `npm publish`. +const DEPENDENCY_SCRIPTS = ["preinstall", "install", "postinstall"]; +const PROJECT_SCRIPTS = [...DEPENDENCY_SCRIPTS, "prepublish", "preprepare", "prepare", "postprepare", "dependencies"]; +// pnpm pack leaves these out of the published package.json (checked with pnpm 12.2). +const PACK_ONLY_SCRIPTS = ["prepare", "prepack", "postpack", "prepublishOnly", "publish", "postpublish"]; const readJson = (file) => JSON.parse(readFileSync(file, "utf8")); const keyOf = (name, version) => `${name}@${version}`; @@ -28,9 +39,12 @@ export function lockIntegrity(text) { return out; } -/** Lifecycle scripts npm would run when installing this package (binding.gyp implies one). */ -export function installScripts(manifest, dir) { - const found = INSTALL_SCRIPTS.filter((s) => manifest.scripts?.[s]); +/** + * Lifecycle scripts npm would run when installing this package (binding.gyp implies one): as a + * registry dependency, or with `project` as the project installed in its own folder. + */ +export function installScripts(manifest, dir, { project = false } = {}) { + const found = (project ? PROJECT_SCRIPTS : DEPENDENCY_SCRIPTS).filter((s) => manifest.scripts?.[s]); if (!found.length && dir && existsSync(join(dir, "binding.gyp"))) found.push("install (binding.gyp)"); return found; } @@ -58,10 +72,13 @@ const DEP_FIELDS = ["dependencies", "optionalDependencies", "peerDependencies"]; /** * The manifest as pnpm publishes it: `workspace:*` becomes the sibling's exact version, - * `workspace:^` and `workspace:~` a range on it, `workspace:` the spec itself. + * `workspace:^` and `workspace:~` a range on it, `workspace:` the spec itself, and the + * scripts that run only to pack or publish are gone. */ export function publishedManifest(manifest, versions) { const out = { ...manifest }; + if (manifest.scripts) + out.scripts = Object.fromEntries(Object.entries(manifest.scripts).filter(([s]) => !PACK_ONLY_SCRIPTS.includes(s))); for (const f of DEP_FIELDS) { if (!manifest[f]) continue; out[f] = Object.fromEntries( diff --git a/scripts/shrinkwrap.test.mjs b/scripts/shrinkwrap.test.mjs index 160fe67d..c8fc8c01 100644 --- a/scripts/shrinkwrap.test.mjs +++ b/scripts/shrinkwrap.test.mjs @@ -81,6 +81,28 @@ test("finds install scripts, including an implicit node-gyp build", () => { } }); +test("the published package itself also runs the prepare scripts, a registry dependency does not", () => { + // `npm ci` in the package folder (the Homebrew formula) runs these; pnpm pack keeps them. + const scripts = { prepublish: "a", preprepare: "b", prepare: "c", postprepare: "d", dependencies: "e", prepack: "f" }; + assert.deepEqual(installScripts({ scripts }, undefined, { project: true }), [ + "prepublish", + "preprepare", + "prepare", + "postprepare", + "dependencies", + ]); + // npm runs only preinstall, install and postinstall for a dependency from the registry. + assert.deepEqual(installScripts({ scripts }), []); + // pnpm pack drops prepare (and prepack) from the published manifest, so only the others ship. + const published = publishedManifest({ name: "app", scripts }, new Map()); + assert.deepEqual(installScripts(published, undefined, { project: true }), [ + "prepublish", + "preprepare", + "postprepare", + "dependencies", + ]); +}); + test("flags dependencies that are not exact versions", () => { assert.deepEqual( inexactDependencies({ From 4c50c764bcb1aa2ca89def7900389713a5290d15 Mon Sep 17 00:00:00 2001 From: William Frank Monroy Mamani Date: Mon, 30 Nov 2026 00:48:02 -0600 Subject: [PATCH 2/3] docs(release): list Harden-Runner per job, scope the standalone checks, add the tap bump - RELEASING.md: which jobs block, which audit and which run without Harden-Runner (the macOS jobs of ci, install and bench, and ci's Windows job); the Homebrew formula bump after every turno-cli release. - SECURITY.md and standalone.yml: only the embedded Node.js archives are checked against a checksum; setup-node and action-setup are pinned by action SHA. - The shrinkwrap test checks pack-check's view of the published manifest instead of the list. - bench/install-size.mjs records the load average; rerun result, and the 0.2.0 page cites the file sizes, which do not vary between runs as disk usage does. --- .github/workflows/standalone.yml | 7 +++-- SECURITY.md | 8 +++-- apps/docs/content/releases/cli/0-2-0.mdx | 2 +- bench/install-size.mjs | 7 +++-- .../2026-11-30-m3-16gb-install-size.json | 21 ++++++++----- docs/RELEASING.md | 31 ++++++++++++++----- scripts/shrinkwrap.test.mjs | 26 ++++------------ 7 files changed, 57 insertions(+), 45 deletions(-) diff --git a/.github/workflows/standalone.yml b/.github/workflows/standalone.yml index 07663ced..e1ce171c 100644 --- a/.github/workflows/standalone.yml +++ b/.github/workflows/standalone.yml @@ -66,9 +66,10 @@ jobs: steps: # Audit mode only: on GitHub's macOS runners Harden-Runner can log connections but not # block them (block mode is Linux only). The job holds no write credential: contents: read, - # no id-token, no secrets. Its downloads are checked instead: the Node.js archives - # (nodejs.org) against the SHA-256 in standalone-node.json, the packages (registry.npmjs.org) - # against the integrity in pnpm-lock.yaml or npm-shrinkwrap.json. + # no id-token, no secrets. The Node.js archives it embeds are checked against the SHA-256 + # in standalone-node.json and the packages against pnpm-lock.yaml or npm-shrinkwrap.json; + # the Node.js and pnpm it runs with (setup-node, action-setup) are pinned by action SHA + # but not checksummed. - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit diff --git a/SECURITY.md b/SECURITY.md index b15fb790..09dd87fd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -237,9 +237,11 @@ credential lives. The release jobs on Linux (the version pull request, tests and publishing, tagging, the upload of the standalone archives) can reach only the hosts on their allow list (Harden-Runner in block mode). The job that builds the standalone turno-browser executables runs on macOS, where Harden-Runner can only log connections, not block them: it -holds no write credential and checks what it downloads (Node.js against a pinned SHA-256, -packages against their lockfile integrity), and a separate Linux job with an allow list attests -and uploads its archives. `turno-cli` and `turno-browser` ship an `npm-shrinkwrap.json`, so +holds no write credential, checks the Node.js archives it embeds against a pinned SHA-256 and +installs packages against their lockfile integrity, and a separate Linux job with an allow list +attests and uploads its archives. The Node.js and pnpm that job runs with come from +actions/setup-node and pnpm/action-setup, pinned by commit SHA but not checked against a +checksum. `turno-cli` and `turno-browser` ship an `npm-shrinkwrap.json`, so `npm install --global` from the registry and the Homebrew formula (`npm ci` in the package folder) install the exact dependency tree that CI tested, and nothing in it runs an install script. Installing a downloaded tarball (`npm install --global ./turno-cli-.tgz`) does diff --git a/apps/docs/content/releases/cli/0-2-0.mdx b/apps/docs/content/releases/cli/0-2-0.mdx index 7c25bb29..57d03ff3 100644 --- a/apps/docs/content/releases/cli/0-2-0.mdx +++ b/apps/docs/content/releases/cli/0-2-0.mdx @@ -140,7 +140,7 @@ turno mcp savings - **Secrets**: `turno secret set` no longer passes the value as a command argument. On Linux, `turno secret` and `keychain:` references use the Secret Service through `secret-tool`. - **Private files**: turno's folders are created 0700 and the files it writes 0600. Backups are private and pruned after 30 days, always keeping the newest 10. - **`turno open`**: accepts only http(s) and mailto links, and works on Linux. -- **A lighter, locked install**: `turno-cli` no longer pulls in `turno-browser` and `turno-fonts` (a clean global install takes 27.7 MiB on disk, down from 51.4 MiB for 0.1.1; [measured](https://github.com/wimo-dev/turno/blob/main/bench/results/2026-11-30-m3-16gb-install-size.json)), and both packages ship an `npm-shrinkwrap.json`. No package in either tree runs an install script. +- **A lighter, locked install**: `turno-cli` no longer pulls in `turno-browser` and `turno-fonts` (a clean global install holds 18.5 MB of files in 97 packages, down from 43.1 MB in 100 for 0.1.1; [measured](https://github.com/wimo-dev/turno/blob/main/bench/results/2026-11-30-m3-16gb-install-size.json)), and both packages ship an `npm-shrinkwrap.json`. No package in either tree runs an install script. ## Fixes diff --git a/bench/install-size.mjs b/bench/install-size.mjs index fe7d674f..483b9be8 100644 --- a/bench/install-size.mjs +++ b/bench/install-size.mjs @@ -9,12 +9,13 @@ // measurement should not run third-party code. A version without an npm-shrinkwrap.json (before // 0.2.0) resolves its dependency ranges to what the registry has today. // Size is the sum of the file sizes under lib/node_modules (MiB, and MB in parentheses) and the -// disk usage `du -sk` reports for it; packages are the folders with a package.json under it, +// disk usage `du -sk` reports for it (which varies by a few MiB between runs of the same tree on +// APFS; the file sizes do not); packages are the folders with a package.json under it, // turno-cli included. import { execFileSync } from "node:child_process"; import { lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; -import { cpus, platform, release, tmpdir, totalmem } from "node:os"; +import { cpus, loadavg, platform, release, tmpdir, totalmem } from "node:os"; import { join } from "node:path"; import { parseArgs } from "node:util"; @@ -27,6 +28,7 @@ const { values } = parseArgs({ const MIB = 1024 * 1024; const startedAt = new Date(); +const loadAtStart = loadavg().map((n) => Math.round(n * 100) / 100); const npmVersion = execFileSync("npm", ["--version"], { encoding: "utf8" }).trim(); function osName() { @@ -137,6 +139,7 @@ const result = { memoryGiB: Math.round(totalmem() / 1024 ** 3), os: osName(), }, + loadAverageAtStart: loadAtStart, node: process.version, npm: npmVersion, rows, diff --git a/bench/results/2026-11-30-m3-16gb-install-size.json b/bench/results/2026-11-30-m3-16gb-install-size.json index 8c95732d..6660b408 100644 --- a/bench/results/2026-11-30-m3-16gb-install-size.json +++ b/bench/results/2026-11-30-m3-16gb-install-size.json @@ -1,9 +1,9 @@ { "version": 1, "kind": "turno-cli-install-size", - "startedAt": "2026-11-30T06:20:14.535Z", - "startedAtMonterrey": "2026-11-30 00:20:14", - "finishedAt": "2026-11-30T06:20:40.327Z", + "startedAt": "2026-11-30T06:41:05.339Z", + "startedAtMonterrey": "2026-11-30 00:41:05", + "finishedAt": "2026-11-30T06:43:56.591Z", "command": "node bench/install-size.mjs --versions 0.1.1,0.2.0,0.6.3", "install": "npm install --global --prefix --ignore-scripts --no-audit --no-fund turno-cli@", "machine": { @@ -11,6 +11,11 @@ "memoryGiB": 16, "os": "macOS 27.2.1" }, + "loadAverageAtStart": [ + 181.61, + 94.95, + 79.73 + ], "node": "v26.13.0", "npm": "11.20.0", "rows": [ @@ -22,8 +27,8 @@ "bytes": 43109463, "mib": 41.1, "mb": 43.1, - "diskMiB": 51.4, - "seconds": 7.8 + "diskMiB": 54.6, + "seconds": 67.2 }, { "version": "0.2.0", @@ -33,8 +38,8 @@ "bytes": 18541668, "mib": 17.7, "mb": 18.5, - "diskMiB": 27.7, - "seconds": 9.6 + "diskMiB": 27.8, + "seconds": 50.5 }, { "version": "0.6.3", @@ -45,7 +50,7 @@ "mib": 18, "mb": 18.9, "diskMiB": 28.2, - "seconds": 5 + "seconds": 40.7 } ] } diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 74c874fd..4159f8e3 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -125,6 +125,18 @@ After a `turno-browser` release, publish its MCP Registry entry by hand from a c organization roles, and the namespace `io.github.wimo-dev` needs an organization owner), then `mcp-publisher publish packages/browser/server.json` and `mcp-publisher logout`. +After every `turno-cli` release, bump the Homebrew formula by hand; nothing does it +automatically, and `brew install turno` stays on the old version until it is done. In a clone +of `wimo-dev/homebrew-turno`, on a branch `turno-`: + +1. Download the tarball into an empty temporary folder: + `curl -sSfLO "$(npm view turno-cli@ dist.tarball)"`. Check that its sha512 (base64) + matches `npm view turno-cli@ dist.integrity`. +2. In `Formula/turno.rb`, set `url` to that tarball URL and `sha256` to + `shasum -a 256 turno-cli-.tgz`. +3. Open a pull request titled `turno ` and merge it once its `formula` workflow + (audit, install and test on macOS and Linux) passes. + `pnpm pack:check` runs the tarball check locally. Prereleases: `pnpm changeset pre enter next`, then releases go to the `next` dist-tag (`turno upgrade --channel next` follows them); `pnpm changeset pre exit` ends it. @@ -163,14 +175,17 @@ Releases after that need nothing by hand. The same steps apply to any other new - Workflows: `permissions: {}` at the top and the minimum per job, every action pinned to a full commit SHA (Dependabot keeps them current), `persist-credentials: false`, no - `pull_request_target`, no cache in the release workflow. Harden-Runner blocks every host - outside the allow list of each release job on Linux (the four jobs of `release.yml`, the - Linux smoke test and the upload of `standalone.yml`) and audits everything else: the other - workflows, and the macOS and Windows jobs of `standalone.yml`, because GitHub's macOS and - Windows runners support only its audit mode. When a release job fails with a blocked - connection, see "Egress allow lists" below. - `zizmor.yml` lints the workflows on every change to `.github/`; `scorecard.yml` runs the - OpenSSF Scorecard weekly. + `pull_request_target`, no cache in the release workflow. `zizmor.yml` lints the workflows on + every change to `.github/`; `scorecard.yml` runs the OpenSSF Scorecard weekly. Harden-Runner, + by job: + - Block mode, with an allow list each: the four jobs of `release.yml`, and the Linux smoke + job and the upload job of `standalone.yml`. When one fails with a blocked connection, see + "Egress allow lists" below. + - Audit mode: the build job and the macOS and Windows smoke jobs of `standalone.yml` (GitHub's + macOS and Windows runners support only audit mode), and the Linux jobs of `ci.yml`, + `install.yml`, `bench.yml`, `docs.yml`, `scorecard.yml` and `zizmor.yml`. + - None: the macOS jobs of `ci.yml`, `install.yml` and `bench.yml`, and the Windows job of + `ci.yml`. - Dependencies: pnpm waits three days before installing a newly published version (`minimumReleaseAge`), refuses a version that lost its provenance (`trustPolicy: no-downgrade`) and refuses an unsupported Node (`engineStrict`). Dependabot opens one grouped diff --git a/scripts/shrinkwrap.test.mjs b/scripts/shrinkwrap.test.mjs index c8fc8c01..d01c0143 100644 --- a/scripts/shrinkwrap.test.mjs +++ b/scripts/shrinkwrap.test.mjs @@ -81,26 +81,12 @@ test("finds install scripts, including an implicit node-gyp build", () => { } }); -test("the published package itself also runs the prepare scripts, a registry dependency does not", () => { - // `npm ci` in the package folder (the Homebrew formula) runs these; pnpm pack keeps them. - const scripts = { prepublish: "a", preprepare: "b", prepare: "c", postprepare: "d", dependencies: "e", prepack: "f" }; - assert.deepEqual(installScripts({ scripts }, undefined, { project: true }), [ - "prepublish", - "preprepare", - "prepare", - "postprepare", - "dependencies", - ]); - // npm runs only preinstall, install and postinstall for a dependency from the registry. - assert.deepEqual(installScripts({ scripts }), []); - // pnpm pack drops prepare (and prepack) from the published manifest, so only the others ship. - const published = publishedManifest({ name: "app", scripts }, new Map()); - assert.deepEqual(installScripts(published, undefined, { project: true }), [ - "prepublish", - "preprepare", - "postprepare", - "dependencies", - ]); +test("the published package is checked as the project npm ci installs, after pnpm pack drops its scripts", () => { + // pack-check's view: prepare and prepack never ship, the prepare hooks npm ci runs do. + const project = (scripts) => + installScripts(publishedManifest({ name: "app", scripts }, new Map()), undefined, { project: true }); + assert.deepEqual(project({ build: "tsc", prepare: "husky", prepack: "pnpm build" }), []); + assert.deepEqual(project({ prepare: "husky", postprepare: "node x.js" }), ["postprepare"]); }); test("flags dependencies that are not exact versions", () => { From 1e6f0e8ad53a6d3c5b23a4867ae91d149aa2a682 Mon Sep 17 00:00:00 2001 From: William Frank Monroy Mamani Date: Mon, 30 Nov 2026 02:18:34 -0600 Subject: [PATCH 3/3] chore(bench): record the install-size start time in UTC only --- bench/install-size.mjs | 1 - bench/results/2026-11-30-m3-16gb-install-size.json | 1 - 2 files changed, 2 deletions(-) diff --git a/bench/install-size.mjs b/bench/install-size.mjs index 483b9be8..977febb6 100644 --- a/bench/install-size.mjs +++ b/bench/install-size.mjs @@ -130,7 +130,6 @@ const result = { version: 1, kind: "turno-cli-install-size", startedAt: startedAt.toISOString(), - startedAtMonterrey: startedAt.toLocaleString("sv-SE", { timeZone: "America/Monterrey" }), finishedAt: new Date().toISOString(), command: `node bench/install-size.mjs --versions ${values.versions}`, install: "npm install --global --prefix --ignore-scripts --no-audit --no-fund turno-cli@", diff --git a/bench/results/2026-11-30-m3-16gb-install-size.json b/bench/results/2026-11-30-m3-16gb-install-size.json index 6660b408..b5cd3083 100644 --- a/bench/results/2026-11-30-m3-16gb-install-size.json +++ b/bench/results/2026-11-30-m3-16gb-install-size.json @@ -2,7 +2,6 @@ "version": 1, "kind": "turno-cli-install-size", "startedAt": "2026-11-30T06:41:05.339Z", - "startedAtMonterrey": "2026-11-30 00:41:05", "finishedAt": "2026-11-30T06:43:56.591Z", "command": "node bench/install-size.mjs --versions 0.1.1,0.2.0,0.6.3", "install": "npm install --global --prefix --ignore-scripts --no-audit --no-fund turno-cli@",