Repository navigation
fix(dependencies): pin override for got to 11.8.5 / patch download for compat - #187
Open
ajaynes-godaddy wants to merge 2 commits into
Open
ajaynes-godaddy wants to merge 2 commits into
ajaynes-godaddy wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pins
gotto11.8.5, resolving Dependabot's security update that was otherwise stuck on an unpatchablegot@7.1.0/8.3.2. Unlike the previous overrides in this series, a version pin alone isn't enough here —got's option API changed enough between these versions that the real consumer breaks outright, so this PR also patches that consumer's two call sites viapatch-package.Details
gulp-imagemin'simagemin-gifsicle/imagemin-mozjpeg/imagemin-optipngplugins each wrap a native binary (gifsicle/mozjpeg/optipng-bin) that falls back tobin-build/bin-wrapperwhen no prebuilt binary is cached — both of which pull indownload, which pulls ingot. Two separate chains land on two different vulnerable versions:bin-build→download@6.2.5→got@^7.0.0, andbin-wrapper→download@7.1.0→got@^8.3.1. Neither range has a patched release; the fix landed in11.8.5.download's own code callsgot.stream(uri, {encoding: null, agent, rejectUnauthorized, ...opts})— a calling conventiongotdropped well beforev11:encoding: nullneeds to beresponseType: 'buffer',agentneeds to be{http, https}instead of a bareAgentinstance,rejectUnauthorizedneeds to move underhttps: {rejectUnauthorized}, and theredirectevent's next-URL is nownextOptions.url(aURLinstance) instead of a flatnextOptions.hrefstring. Installedgot@11.8.5directly against the realdownloadcode and confirmed it throws immediately (TypeError: To get a Buffer, set 'options.responseType' to 'buffer' instead).download(node_modules/download@6.2.5and the nestednode_modules/bin-wrapper/node_modules/download@7.1.0) viapatch-package, translating the four option shapes above without changing either package's own public API. Verified against real local HTTP/HTTPS servers: plain download, redirect-following download, the actual tar.gz extract-to-disk path (the real binary-fetch use case), and TLS certificate validation in both strict andrejectUnauthorized: falsemodes — all byte-identical to pre-patch behavior.patch-packagealone isn't sufficient either: npm runs a dependency's own lifecycle scripts before the root project'spostinstall(scripts run bottom-up through the tree), sogifsicle/mozjpeg/optipng-bin's own install scripts — which is what actually calls intodownload— run and fail against the still-unpatched code on a fresh install, beforepatch-packagegets a chance to fix it. Addedscripts/ensure-imagemin-binaries.js, chained afterpatch-packageinpostinstall, which re-runs each of the three packages' own install step oncedownloadis guaranteed to be patched. This converts a slow/toolchain-dependent fallback build into the fast prebuilt-binary fetch, and is a no-op (just prints a success message) if the first attempt already landed on the primary path.mozjpeg/optipng-binareoptionalDependenciesofimagemin, so if their first (pre-patch) attempt fails outright rather than falling back gracefully, npm silently drops them fromnode_modulesrather than failing the install — in which case there's nothing left for the retry script to re-run. This self-heals on the very nextnpm install(confirmed), sincedownloadis already patched by then and the normal dependency-reconciliation pass reinstalls whatever's missing.got: alert 18 (medium, CVE-2022-33987, patched at11.8.5) — this clears it and should auto-resolve once this merges.QA
Steps
gotresolved to the patched version:node -p "require('./node_modules/got/package.json').version"gifsicle/mozjpeg/optipng-binall installed successfully (if any are missing after this first install on your machine, that's the optionalDependency/script-ordering race described above — runnpm installa second time and they'll be there):presentgulp-imageminpipeline — the same onesake'sminifyImagesTaskruns — processes real PNG and GIF files end-to-end with no errors:TOTAL: 2and noFAILEDerrornpm testBefore merge
npm test) passes unchanged; thedownloadcall-site patch itself was verified manually via the QA steps above against real HTTP/HTTPS servers (not something the current test suite's scope covers).download's public API is unchanged, confirmed via the QA steps above.🤖 Generated with Claude Code