Skip to content

Commit b0a3bb4

Browse files
committed
chore(security): shim minimatch instead of brace-expansion
Der vorherige Ansatz hat brace-expansion selbst ersetzt. Das funktioniert zwar technisch, der Dependency-Review-Scan sieht das Paket aber weiterhin als brace-expansion 1.x und schlägt an. Die Version künstlich über 5.0.7 zu heben wäre nur Kosmetik gegenüber dem Scanner. Stattdessen jetzt an der richtigen Stelle angesetzt: minimatch wird per resolutions auf einen Shim gemappt, der minimatch 10 unter der callable minimatch@3 API bereitstellt. minimatch 10 hängt selbst schon an brace-expansion ^5.0.5, damit löst brace-expansion regulär auf 5.0.8 auf und die verwundbare 1.x-Linie ist komplett aus dem Baum. Nichts wird maskiert, das Paket ist echt gepatcht. Beide Consumer (serve-handler, docusaurus-lunr-search) rufen minimatch ausschließlich als Funktion auf. Ein A/B-Vergleich gegen echtes minimatch 3.1.5 über neun Glob-, Globstar- und Brace-Patterns liefert identische Ergebnisse. Geprüft mit yarn typecheck, yarn build inklusive lunr-Indexierung (unverändert 37 Dokumente) und einem serve-handler-Smoketest, bei dem das Header-Glob-Matching über minimatch tatsächlich greift. Geänderte Dateien: - package.json - yarn.lock - patches/minimatch-compat/package.json (neu) - patches/minimatch-compat/index.js (neu) - patches/brace-expansion-compat/ (entfernt)
1 parent f50fbf7 commit b0a3bb4

6 files changed

Lines changed: 73 additions & 53 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"serialize-javascript": "^7.0.5",
4242
"follow-redirects": "^1.16.0",
4343
"@babel/plugin-transform-modules-systemjs": "^7.29.4",
44-
"brace-expansion": "file:./patches/brace-expansion-compat",
44+
"minimatch": "file:./patches/minimatch-compat",
4545
"qs": "^6.15.3",
4646
"**/sockjs/uuid": "^11.1.1",
4747
"**/webpack-bundle-analyzer/ws": "^7.5.11",

patches/brace-expansion-compat/index.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

patches/brace-expansion-compat/package.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

patches/minimatch-compat/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
// Why this exists:
4+
//
5+
// brace-expansion 1.x is affected by GHSA-mh99-v99m-4gvg (unbounded expansion,
6+
// OOM crash) and the 1.x line never got a patch. The fix only landed in 5.0.8.
7+
// The only thing still pulling brace-expansion 1.x is minimatch@3, which
8+
// serve-handler and docusaurus-lunr-search depend on.
9+
//
10+
// brace-expansion 5 cannot be dropped into minimatch@3 because its CommonJS
11+
// build exports an object instead of a callable. Going the other way works
12+
// though: minimatch 10 already depends on the patched brace-expansion 5.x. Its
13+
// own CommonJS build is not callable either, but that is easy to bridge, and
14+
// unlike brace-expansion the API surface here is small and stable.
15+
//
16+
// So this shim is mapped over "minimatch" via yarn resolutions. Result:
17+
// minimatch@3 is gone, brace-expansion resolves to a patched 5.x, and the two
18+
// consumers keep the callable signature they expect.
19+
20+
const mm = require('minimatch-modern');
21+
22+
const minimatch = mm.minimatch;
23+
24+
// minimatch@3 hangs its extras off the exported function (Minimatch, filter,
25+
// match, makeRe, braceExpand, defaults, sep, GLOBSTAR). Carry them over so the
26+
// shim is shaped like the module it replaces.
27+
for (const key of Object.keys(mm)) {
28+
if (key === 'minimatch') continue;
29+
try {
30+
minimatch[key] = mm[key];
31+
} catch (err) {
32+
// read-only function properties (name, length) are not overwritable
33+
}
34+
}
35+
36+
module.exports = minimatch;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "minimatch-compat",
3+
"version": "3.1.6",
4+
"description": "CommonJS compat shim: serves minimatch 10 under the callable minimatch@3 API, so the tree can drop the unpatchable brace-expansion 1.x.",
5+
"license": "ISC",
6+
"main": "index.js",
7+
"files": [
8+
"index.js"
9+
],
10+
"dependencies": {
11+
"minimatch-modern": "npm:minimatch@^10.2.5"
12+
},
13+
"engines": {
14+
"node": ">=20.0"
15+
}
16+
}

yarn.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,18 +2151,6 @@
21512151
dependencies:
21522152
"@hapi/hoek" "^9.0.0"
21532153

2154-
"@isaacs/balanced-match@^4.0.1":
2155-
version "4.0.1"
2156-
resolved "https://registry.yarnpkg.com/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz#3081dadbc3460661b751e7591d7faea5df39dd29"
2157-
integrity sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==
2158-
2159-
"@isaacs/brace-expansion@^5.0.1":
2160-
version "5.0.1"
2161-
resolved "https://registry.yarnpkg.com/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz#0ef5a92d91f2fff2a37646ce54da9e5f599f6eff"
2162-
integrity sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==
2163-
dependencies:
2164-
"@isaacs/balanced-match" "^4.0.1"
2165-
21662154
"@jest/schemas@^29.6.3":
21672155
version "29.6.3"
21682156
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03"
@@ -3824,6 +3812,11 @@ bail@^2.0.0:
38243812
resolved "https://registry.yarnpkg.com/bail/-/bail-2.0.2.tgz#d26f5cd8fe5d6f832a31517b9f7c356040ba6d5d"
38253813
integrity sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==
38263814

3815+
balanced-match@^4.0.2:
3816+
version "4.0.4"
3817+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-4.0.4.tgz#bfb10662feed8196a2c62e7c68e17720c274179a"
3818+
integrity sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==
3819+
38273820
baseline-browser-mapping@^2.10.12:
38283821
version "2.10.17"
38293822
resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.10.17.tgz#435c101835c314c2d89d768795e1ea79941fafd3"
@@ -3908,10 +3901,12 @@ boxen@^7.0.0:
39083901
widest-line "^4.0.1"
39093902
wrap-ansi "^8.1.0"
39103903

3911-
brace-expansion@^1.1.7, "brace-expansion@file:./patches/brace-expansion-compat":
3912-
version "1.1.17"
3904+
brace-expansion@^5.0.5:
3905+
version "5.0.8"
3906+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-5.0.8.tgz#135ad0d8d808eb18eb5e0ec9a21f3a0b92ef18cf"
3907+
integrity sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==
39133908
dependencies:
3914-
"@isaacs/brace-expansion" "^5.0.1"
3909+
balanced-match "^4.0.2"
39153910

39163911
braces@^3.0.3, braces@~3.0.2:
39173912
version "3.0.3"
@@ -7277,12 +7272,17 @@ minimalistic-assert@^1.0.0:
72777272
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
72787273
integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==
72797274

7280-
minimatch@3.1.5, minimatch@^3.1.2:
7281-
version "3.1.5"
7282-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.5.tgz#580c88f8d5445f2bd6aa8f3cadefa0de79fbd69e"
7283-
integrity sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==
7275+
"minimatch-modern@npm:minimatch@^10.2.5":
7276+
version "10.2.5"
7277+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.5.tgz#bd48687a0be38ed2961399105600f832095861d1"
7278+
integrity sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==
7279+
dependencies:
7280+
brace-expansion "^5.0.5"
7281+
7282+
minimatch@3.1.5, minimatch@^3.1.2, "minimatch@file:./patches/minimatch-compat":
7283+
version "3.1.6"
72847284
dependencies:
7285-
brace-expansion "^1.1.7"
7285+
minimatch-modern "npm:minimatch@^10.2.5"
72867286

72877287
minimist@^1.2.0:
72887288
version "1.2.8"

0 commit comments

Comments
 (0)