Skip to content

Install tar 8 under sqlite3, node-gyp and node-pre-gyp (clone and Docker installs) - #468

Merged
grahamegrieve merged 8 commits into
HealthIntersections:mainfrom
jmandel:tar8-overrides
Dec 4, 2026
Merged

grahamegrieve merged 8 commits into
HealthIntersections:mainfrom
jmandel:tar8-overrides

Conversation

@jmandel

@jmandel jmandel commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

tar 7 has 19 open advisories that are fixed only in tar 8. FHIRsmith's own use of tar is already on 8, but sqlite3, node-gyp and @mapbox/node-pre-gyp (the last two come with roaring) each still depend on tar 7, and none has a release on tar 8. This gives them tar 8 for a clone and for the Docker image.

What it does

  • tar 8 under the three packages. "overrides": { "tar": "$tar" } alone doesn't work, because tar 8 changed two calls they make: extract() with no file returned a stream and now returns a Promise (node-gyp and node-pre-gyp pipe a download into it, so roaring fails to install), and extract({ sync: true }) is no longer synchronous (sqlite3's from-source build then leaves a VERSION file that hides the C++ <version> header on macOS and Windows). vendor/tar-stream-shim is tar 8 with those two calls as they were, about 40 lines; package.json overrides installs it as tar under the three packages. vendor/README.md has the details and how to remove it once they move to tar 8.
  • allowScripts for sqlite3, better-sqlite3, roaring and bcrypt. npm 12 (and recent npm 11) only runs the install scripts a project approves; without this, npm install leaves the first three without a native binary and reports no error.
  • engines: ^24. roaring 2.7.0 has no prebuilt binary for Node 26 and does not compile there (V8 API removals). As an optional dependency it is skipped silently, and the sqlite-v2 providers then can't load. The README says the same.
  • Audit. audit-allowlist.json is empty again. The fresh-install audit step gets its own list, audit-allowlist-published.json, and utilities/audit-check.js takes an entry for a whole package (with a test).
  • Install check workflow (new, runs when package.json, the lock file or vendor/ change): on Linux, macOS and Windows, npm ci, no tar older than 8 installed, the native modules load, sqlite3 builds from source, and the packed shim matches its source.

What it doesn't do

npm doesn't apply a package's overrides when that package is installed from the registry, so npm install fhirsmith still gets tar 7 under the three packages. Nothing in this repository can change that; it goes away when they release on tar 8. The changelog says so, and the fresh-install audit accepts tar there with the reason and an expiry (2027-03-01). The three use tar only while installing, on archives from fixed sources.

Tested

  • Install check on a fork: Linux and Windows pass on this commit. macOS passed on the commit before (the only change since is to the shim comparison step, the bcrypt approval and the changelog); its run on this commit was still waiting for a runner when this was opened.
  • Linux, locally: npm ci on npm 11 (Node 24) and npm 12; sqlite3 and roaring built from source through the shim; npm audit clean at high, and at moderate with --omit=dev; the fresh-install audit step exits 0 with 19 tar advisories accepted; jest 2,612 passed, 84 skipped, 0 failed (run before the last three commits; the audit-check tests were rerun after); Docker image builds with only tar 8.
  • Lock file: npm install --package-lock-only, npm version followed by it (the release steps), and adding a package all work on npm 11 and npm 12 and keep the three shim entries.
  • The shim's stream form with a good archive, one corrupted in the middle, a truncated one and a file that isn't an archive: the first extracts, the others end with an error and none hangs.

The PR pipeline's "Run npm audit" step fails on main at present (one allowlisted tar advisory, 19 published); it passes on this branch.

🤖 Generated with Claude Code

jmandel and others added 8 commits December 3, 2026 15:35
…rough a small shim

tar 7 has open advisories that are fixed only in tar 8. sqlite3, node-gyp and
@mapbox/node-pre-gyp still ask for tar 7, and two of their calls changed in tar 8,
so a plain override to tar 8 breaks installs that build from source or download a
prebuilt binary.

vendor/tar-stream-shim is tar 8 with those two call forms restored
(extract() with no file returning a writable stream, and extract({sync: true})).
package.json overrides point the three packages at it, so the only tar code in
node_modules is tar 8.

The lock file changes only in the tar entries. The Dockerfile copies the shim in
before npm ci. The Install check workflow installs on Linux, macOS and Windows,
checks no tar older than 8 is present, loads the native modules and builds
sqlite3 from source.

Co-Authored-By: Claude <noreply@anthropic.com>
npm 12 (and recent npm 11) runs a dependency's install script only when the
project approves it in package.json allowScripts. Without that, npm install
finishes without error and these three packages have no native binary, so the
server cannot open a database. Older npm ignores the field.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
When tar stopped reading part way (not an archive, a bad entry), the stream handed to
node-gyp and node-pre-gyp waited for a drain that never came, so a failed download hung the
install instead of failing it. The error now destroys the stream. Also treat tar's f alias as
file.

Co-Authored-By: Claude <noreply@anthropic.com>
… the overrides cover

npm doesn't apply a package's overrides when it is installed from the registry, so
npm install fhirsmith still gets tar 7 under sqlite3, node-gyp and node-pre-gyp. The fresh
install audit has its own allowlist for that (audit-allowlist-published.json), and
audit-check.js takes an entry for a whole package, so the next tar 7 advisory doesn't fail a
check nothing can be done about. The changelog and vendor/README.md say the overrides cover a
clone and the Docker image only.

vendor/ is left out of the published package, and the Install check fails if the packed shim
and its source differ.

Co-Authored-By: Claude <noreply@anthropic.com>
…pprove bcrypt's install script

Git for Windows' tar could not open the runner's temp folder. bcrypt carries prebuilt
binaries, and its install script builds it where there is none. The allowScripts and engines
changelog entries move from Security to Changed.

Co-Authored-By: Claude <noreply@anthropic.com>
@grahamegrieve
grahamegrieve merged commit 3dbcf78 into HealthIntersections:main Dec 4, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants