@hubspot/cms-dev-server 1.2.85 → 1.2.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generateFieldsCli.js +26 -13
- package/dist/generateJsonFromJsx.js +26 -13
- package/dist/index.js +28 -15
- package/dist/internalSsr.js +28 -15
- package/dist/run.js +28 -15
- package/dist/storybook-main/main.js +30 -17
- package/dist/validateFieldsCli.js +26 -13
- package/package.json +3 -3
|
@@ -199,34 +199,47 @@ function noncePlaceholderPlugin() {
|
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
var MAX_EXTRA_DECODE_PASSES = 3;
|
|
203
|
+
var hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
204
|
+
function isPathTraversal(url2) {
|
|
203
205
|
if (!url2)
|
|
204
206
|
return false;
|
|
205
|
-
|
|
206
|
-
if (!pathname.endsWith(".map"))
|
|
207
|
-
return false;
|
|
208
|
-
let decodedPathname;
|
|
207
|
+
let decodedUrl;
|
|
209
208
|
try {
|
|
210
|
-
|
|
209
|
+
decodedUrl = decodeURI(url2);
|
|
211
210
|
} catch {
|
|
212
211
|
return true;
|
|
213
212
|
}
|
|
214
|
-
|
|
213
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
214
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
215
|
+
if (hasTraversalSegment(pathname))
|
|
216
|
+
return true;
|
|
217
|
+
let nextPathname;
|
|
218
|
+
try {
|
|
219
|
+
nextPathname = decodeURIComponent(pathname);
|
|
220
|
+
} catch {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
if (nextPathname === pathname)
|
|
224
|
+
return false;
|
|
225
|
+
pathname = nextPathname;
|
|
226
|
+
}
|
|
227
|
+
return hasTraversalSegment(pathname);
|
|
215
228
|
}
|
|
216
|
-
function
|
|
217
|
-
if (
|
|
229
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
230
|
+
if (isPathTraversal(req.url)) {
|
|
218
231
|
res.statusCode = 403;
|
|
219
232
|
res.end();
|
|
220
233
|
return;
|
|
221
234
|
}
|
|
222
235
|
next();
|
|
223
236
|
}
|
|
224
|
-
function
|
|
237
|
+
function pathTraversalGuardPlugin() {
|
|
225
238
|
return {
|
|
226
|
-
name: "cms-
|
|
239
|
+
name: "cms-path-traversal-guard",
|
|
227
240
|
apply: "serve",
|
|
228
241
|
configureServer(server) {
|
|
229
|
-
server.middlewares.use(
|
|
242
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
230
243
|
}
|
|
231
244
|
};
|
|
232
245
|
}
|
|
@@ -404,7 +417,7 @@ async function forEachModule(projectRoot, moduleName, run) {
|
|
|
404
417
|
dedupe: ["react", "react-dom", "@hubspot/cms-components", "styled-jsx"]
|
|
405
418
|
},
|
|
406
419
|
plugins: [
|
|
407
|
-
|
|
420
|
+
pathTraversalGuardPlugin(),
|
|
408
421
|
react({
|
|
409
422
|
babel: {
|
|
410
423
|
plugins: [
|
|
@@ -113,34 +113,47 @@ function noncePlaceholderPlugin() {
|
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
var MAX_EXTRA_DECODE_PASSES = 3;
|
|
117
|
+
var hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
118
|
+
function isPathTraversal(url2) {
|
|
117
119
|
if (!url2)
|
|
118
120
|
return false;
|
|
119
|
-
|
|
120
|
-
if (!pathname.endsWith(".map"))
|
|
121
|
-
return false;
|
|
122
|
-
let decodedPathname;
|
|
121
|
+
let decodedUrl;
|
|
123
122
|
try {
|
|
124
|
-
|
|
123
|
+
decodedUrl = decodeURI(url2);
|
|
125
124
|
} catch {
|
|
126
125
|
return true;
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
128
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
129
|
+
if (hasTraversalSegment(pathname))
|
|
130
|
+
return true;
|
|
131
|
+
let nextPathname;
|
|
132
|
+
try {
|
|
133
|
+
nextPathname = decodeURIComponent(pathname);
|
|
134
|
+
} catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (nextPathname === pathname)
|
|
138
|
+
return false;
|
|
139
|
+
pathname = nextPathname;
|
|
140
|
+
}
|
|
141
|
+
return hasTraversalSegment(pathname);
|
|
129
142
|
}
|
|
130
|
-
function
|
|
131
|
-
if (
|
|
143
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
144
|
+
if (isPathTraversal(req.url)) {
|
|
132
145
|
res.statusCode = 403;
|
|
133
146
|
res.end();
|
|
134
147
|
return;
|
|
135
148
|
}
|
|
136
149
|
next();
|
|
137
150
|
}
|
|
138
|
-
function
|
|
151
|
+
function pathTraversalGuardPlugin() {
|
|
139
152
|
return {
|
|
140
|
-
name: "cms-
|
|
153
|
+
name: "cms-path-traversal-guard",
|
|
141
154
|
apply: "serve",
|
|
142
155
|
configureServer(server) {
|
|
143
|
-
server.middlewares.use(
|
|
156
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
144
157
|
}
|
|
145
158
|
};
|
|
146
159
|
}
|
|
@@ -676,7 +689,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
676
689
|
root: webRoot,
|
|
677
690
|
...ssrAndOptimizeDep,
|
|
678
691
|
plugins: [
|
|
679
|
-
|
|
692
|
+
pathTraversalGuardPlugin(),
|
|
680
693
|
hsStaticAssetPlugin(),
|
|
681
694
|
jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
|
|
682
695
|
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
package/dist/index.js
CHANGED
|
@@ -585,34 +585,47 @@ function noncePlaceholderPlugin() {
|
|
|
585
585
|
}
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
|
|
588
|
+
var MAX_EXTRA_DECODE_PASSES = 3;
|
|
589
|
+
var hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
590
|
+
function isPathTraversal(url3) {
|
|
589
591
|
if (!url3)
|
|
590
592
|
return false;
|
|
591
|
-
|
|
592
|
-
if (!pathname.endsWith(".map"))
|
|
593
|
-
return false;
|
|
594
|
-
let decodedPathname;
|
|
593
|
+
let decodedUrl;
|
|
595
594
|
try {
|
|
596
|
-
|
|
595
|
+
decodedUrl = decodeURI(url3);
|
|
597
596
|
} catch {
|
|
598
597
|
return true;
|
|
599
598
|
}
|
|
600
|
-
|
|
599
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
600
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
601
|
+
if (hasTraversalSegment(pathname))
|
|
602
|
+
return true;
|
|
603
|
+
let nextPathname;
|
|
604
|
+
try {
|
|
605
|
+
nextPathname = decodeURIComponent(pathname);
|
|
606
|
+
} catch {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
if (nextPathname === pathname)
|
|
610
|
+
return false;
|
|
611
|
+
pathname = nextPathname;
|
|
612
|
+
}
|
|
613
|
+
return hasTraversalSegment(pathname);
|
|
601
614
|
}
|
|
602
|
-
function
|
|
603
|
-
if (
|
|
615
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
616
|
+
if (isPathTraversal(req.url)) {
|
|
604
617
|
res.statusCode = 403;
|
|
605
618
|
res.end();
|
|
606
619
|
return;
|
|
607
620
|
}
|
|
608
621
|
next();
|
|
609
622
|
}
|
|
610
|
-
function
|
|
623
|
+
function pathTraversalGuardPlugin() {
|
|
611
624
|
return {
|
|
612
|
-
name: "cms-
|
|
625
|
+
name: "cms-path-traversal-guard",
|
|
613
626
|
apply: "serve",
|
|
614
627
|
configureServer(server) {
|
|
615
|
-
server.middlewares.use(
|
|
628
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
616
629
|
}
|
|
617
630
|
};
|
|
618
631
|
}
|
|
@@ -1248,7 +1261,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
1248
1261
|
root: webRoot,
|
|
1249
1262
|
...ssrAndOptimizeDep,
|
|
1250
1263
|
plugins: [
|
|
1251
|
-
|
|
1264
|
+
pathTraversalGuardPlugin(),
|
|
1252
1265
|
hsStaticAssetPlugin(),
|
|
1253
1266
|
jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
|
|
1254
1267
|
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
@@ -1691,7 +1704,7 @@ function trackUsage(action) {
|
|
|
1691
1704
|
eventName: EVENT_NAME,
|
|
1692
1705
|
action,
|
|
1693
1706
|
nodeVersion: getNodeVersionData(),
|
|
1694
|
-
version: "1.2.
|
|
1707
|
+
version: "1.2.86",
|
|
1695
1708
|
os: getPlatform()
|
|
1696
1709
|
};
|
|
1697
1710
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -5637,7 +5650,7 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
5637
5650
|
include: ["react", "react-dom", "react-dom/client"]
|
|
5638
5651
|
},
|
|
5639
5652
|
plugins: [
|
|
5640
|
-
|
|
5653
|
+
pathTraversalGuardPlugin(),
|
|
5641
5654
|
(() => {
|
|
5642
5655
|
const require2 = createRequire2(import.meta.url);
|
|
5643
5656
|
return react2({
|
package/dist/internalSsr.js
CHANGED
|
@@ -737,34 +737,47 @@ function noncePlaceholderPlugin() {
|
|
|
737
737
|
}
|
|
738
738
|
};
|
|
739
739
|
}
|
|
740
|
-
|
|
740
|
+
var MAX_EXTRA_DECODE_PASSES = 3;
|
|
741
|
+
var hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
742
|
+
function isPathTraversal(url) {
|
|
741
743
|
if (!url)
|
|
742
744
|
return false;
|
|
743
|
-
|
|
744
|
-
if (!pathname.endsWith(".map"))
|
|
745
|
-
return false;
|
|
746
|
-
let decodedPathname;
|
|
745
|
+
let decodedUrl;
|
|
747
746
|
try {
|
|
748
|
-
|
|
747
|
+
decodedUrl = decodeURI(url);
|
|
749
748
|
} catch {
|
|
750
749
|
return true;
|
|
751
750
|
}
|
|
752
|
-
|
|
751
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
752
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
753
|
+
if (hasTraversalSegment(pathname))
|
|
754
|
+
return true;
|
|
755
|
+
let nextPathname;
|
|
756
|
+
try {
|
|
757
|
+
nextPathname = decodeURIComponent(pathname);
|
|
758
|
+
} catch {
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
if (nextPathname === pathname)
|
|
762
|
+
return false;
|
|
763
|
+
pathname = nextPathname;
|
|
764
|
+
}
|
|
765
|
+
return hasTraversalSegment(pathname);
|
|
753
766
|
}
|
|
754
|
-
function
|
|
755
|
-
if (
|
|
767
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
768
|
+
if (isPathTraversal(req.url)) {
|
|
756
769
|
res.statusCode = 403;
|
|
757
770
|
res.end();
|
|
758
771
|
return;
|
|
759
772
|
}
|
|
760
773
|
next();
|
|
761
774
|
}
|
|
762
|
-
function
|
|
775
|
+
function pathTraversalGuardPlugin() {
|
|
763
776
|
return {
|
|
764
|
-
name: "cms-
|
|
777
|
+
name: "cms-path-traversal-guard",
|
|
765
778
|
apply: "serve",
|
|
766
779
|
configureServer(server) {
|
|
767
|
-
server.middlewares.use(
|
|
780
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
768
781
|
}
|
|
769
782
|
};
|
|
770
783
|
}
|
|
@@ -1330,13 +1343,15 @@ export {
|
|
|
1330
1343
|
includesHublDataReference,
|
|
1331
1344
|
isFullHeightPreviewEnabled,
|
|
1332
1345
|
isLocalUiDisabled,
|
|
1333
|
-
|
|
1346
|
+
isPathTraversal,
|
|
1334
1347
|
isStorybookStory,
|
|
1335
1348
|
isStylesheetAsset,
|
|
1336
1349
|
isUngatedFor,
|
|
1337
1350
|
jsonStringifyAndEscapeForInlineJS,
|
|
1338
1351
|
namespaceModulePropsShape,
|
|
1339
1352
|
noncePlaceholderPlugin,
|
|
1353
|
+
pathTraversalGuardMiddleware,
|
|
1354
|
+
pathTraversalGuardPlugin,
|
|
1340
1355
|
removeComponentExtension,
|
|
1341
1356
|
removeIndexFromPath,
|
|
1342
1357
|
removeIndexOrTrailingJsFromPath,
|
|
@@ -1350,8 +1365,6 @@ export {
|
|
|
1350
1365
|
scriptTagToLogServerMessages,
|
|
1351
1366
|
serializeIslandDataForInlineScript,
|
|
1352
1367
|
setIn,
|
|
1353
|
-
sourcemapTraversalGuardMiddleware,
|
|
1354
|
-
sourcemapTraversalGuardPlugin,
|
|
1355
1368
|
ungatedAtBuildTimeFor,
|
|
1356
1369
|
virtualClientRenderIslandModuleId
|
|
1357
1370
|
};
|
package/dist/run.js
CHANGED
|
@@ -1478,34 +1478,47 @@ function noncePlaceholderPlugin() {
|
|
|
1478
1478
|
}
|
|
1479
1479
|
};
|
|
1480
1480
|
}
|
|
1481
|
-
|
|
1481
|
+
var MAX_EXTRA_DECODE_PASSES = 3;
|
|
1482
|
+
var hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
1483
|
+
function isPathTraversal(url3) {
|
|
1482
1484
|
if (!url3)
|
|
1483
1485
|
return false;
|
|
1484
|
-
|
|
1485
|
-
if (!pathname.endsWith(".map"))
|
|
1486
|
-
return false;
|
|
1487
|
-
let decodedPathname;
|
|
1486
|
+
let decodedUrl;
|
|
1488
1487
|
try {
|
|
1489
|
-
|
|
1488
|
+
decodedUrl = decodeURI(url3);
|
|
1490
1489
|
} catch {
|
|
1491
1490
|
return true;
|
|
1492
1491
|
}
|
|
1493
|
-
|
|
1492
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
1493
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
1494
|
+
if (hasTraversalSegment(pathname))
|
|
1495
|
+
return true;
|
|
1496
|
+
let nextPathname;
|
|
1497
|
+
try {
|
|
1498
|
+
nextPathname = decodeURIComponent(pathname);
|
|
1499
|
+
} catch {
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
if (nextPathname === pathname)
|
|
1503
|
+
return false;
|
|
1504
|
+
pathname = nextPathname;
|
|
1505
|
+
}
|
|
1506
|
+
return hasTraversalSegment(pathname);
|
|
1494
1507
|
}
|
|
1495
|
-
function
|
|
1496
|
-
if (
|
|
1508
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
1509
|
+
if (isPathTraversal(req.url)) {
|
|
1497
1510
|
res.statusCode = 403;
|
|
1498
1511
|
res.end();
|
|
1499
1512
|
return;
|
|
1500
1513
|
}
|
|
1501
1514
|
next();
|
|
1502
1515
|
}
|
|
1503
|
-
function
|
|
1516
|
+
function pathTraversalGuardPlugin() {
|
|
1504
1517
|
return {
|
|
1505
|
-
name: "cms-
|
|
1518
|
+
name: "cms-path-traversal-guard",
|
|
1506
1519
|
apply: "serve",
|
|
1507
1520
|
configureServer(server) {
|
|
1508
|
-
server.middlewares.use(
|
|
1521
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
1509
1522
|
}
|
|
1510
1523
|
};
|
|
1511
1524
|
}
|
|
@@ -2289,7 +2302,7 @@ function trackUsage(action) {
|
|
|
2289
2302
|
eventName: EVENT_NAME,
|
|
2290
2303
|
action,
|
|
2291
2304
|
nodeVersion: getNodeVersionData(),
|
|
2292
|
-
version: "1.2.
|
|
2305
|
+
version: "1.2.86",
|
|
2293
2306
|
os: getPlatform()
|
|
2294
2307
|
};
|
|
2295
2308
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -6036,7 +6049,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
6036
6049
|
root: webRoot2,
|
|
6037
6050
|
...ssrAndOptimizeDep,
|
|
6038
6051
|
plugins: [
|
|
6039
|
-
|
|
6052
|
+
pathTraversalGuardPlugin(),
|
|
6040
6053
|
hsStaticAssetPlugin(),
|
|
6041
6054
|
jsRenderingGates.includes("CMS:JSRenderer:AnalyzeCmsModules") ? findCmsModules() : null,
|
|
6042
6055
|
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
@@ -6461,7 +6474,7 @@ async function createAppServer(appWebRoot, port, sslEnabled) {
|
|
|
6461
6474
|
include: ["react", "react-dom", "react-dom/client"]
|
|
6462
6475
|
},
|
|
6463
6476
|
plugins: [
|
|
6464
|
-
|
|
6477
|
+
pathTraversalGuardPlugin(),
|
|
6465
6478
|
(() => {
|
|
6466
6479
|
const require2 = createRequire2(import.meta.url);
|
|
6467
6480
|
return react2({
|
|
@@ -594,13 +594,15 @@ __export(dist_exports, {
|
|
|
594
594
|
includesHublDataReference: () => includesHublDataReference,
|
|
595
595
|
isFullHeightPreviewEnabled: () => isFullHeightPreviewEnabled,
|
|
596
596
|
isLocalUiDisabled: () => isLocalUiDisabled,
|
|
597
|
-
|
|
597
|
+
isPathTraversal: () => isPathTraversal,
|
|
598
598
|
isStorybookStory: () => isStorybookStory,
|
|
599
599
|
isStylesheetAsset: () => isStylesheetAsset,
|
|
600
600
|
isUngatedFor: () => isUngatedFor,
|
|
601
601
|
jsonStringifyAndEscapeForInlineJS: () => jsonStringifyAndEscapeForInlineJS,
|
|
602
602
|
namespaceModulePropsShape: () => namespaceModulePropsShape,
|
|
603
603
|
noncePlaceholderPlugin: () => noncePlaceholderPlugin,
|
|
604
|
+
pathTraversalGuardMiddleware: () => pathTraversalGuardMiddleware,
|
|
605
|
+
pathTraversalGuardPlugin: () => pathTraversalGuardPlugin,
|
|
604
606
|
removeComponentExtension: () => removeComponentExtension,
|
|
605
607
|
removeIndexFromPath: () => removeIndexFromPath,
|
|
606
608
|
removeIndexOrTrailingJsFromPath: () => removeIndexOrTrailingJsFromPath,
|
|
@@ -614,8 +616,6 @@ __export(dist_exports, {
|
|
|
614
616
|
scriptTagToLogServerMessages: () => scriptTagToLogServerMessages,
|
|
615
617
|
serializeIslandDataForInlineScript: () => serializeIslandDataForInlineScript,
|
|
616
618
|
setIn: () => setIn,
|
|
617
|
-
sourcemapTraversalGuardMiddleware: () => sourcemapTraversalGuardMiddleware,
|
|
618
|
-
sourcemapTraversalGuardPlugin: () => sourcemapTraversalGuardPlugin,
|
|
619
619
|
ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
|
|
620
620
|
virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
|
|
621
621
|
});
|
|
@@ -713,34 +713,45 @@ function noncePlaceholderPlugin() {
|
|
|
713
713
|
}
|
|
714
714
|
};
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function isPathTraversal(url) {
|
|
717
717
|
if (!url)
|
|
718
718
|
return false;
|
|
719
|
-
|
|
720
|
-
if (!pathname.endsWith(".map"))
|
|
721
|
-
return false;
|
|
722
|
-
let decodedPathname;
|
|
719
|
+
let decodedUrl;
|
|
723
720
|
try {
|
|
724
|
-
|
|
721
|
+
decodedUrl = decodeURI(url);
|
|
725
722
|
} catch {
|
|
726
723
|
return true;
|
|
727
724
|
}
|
|
728
|
-
|
|
725
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
726
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
727
|
+
if (hasTraversalSegment(pathname))
|
|
728
|
+
return true;
|
|
729
|
+
let nextPathname;
|
|
730
|
+
try {
|
|
731
|
+
nextPathname = decodeURIComponent(pathname);
|
|
732
|
+
} catch {
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
if (nextPathname === pathname)
|
|
736
|
+
return false;
|
|
737
|
+
pathname = nextPathname;
|
|
738
|
+
}
|
|
739
|
+
return hasTraversalSegment(pathname);
|
|
729
740
|
}
|
|
730
|
-
function
|
|
731
|
-
if (
|
|
741
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
742
|
+
if (isPathTraversal(req.url)) {
|
|
732
743
|
res.statusCode = 403;
|
|
733
744
|
res.end();
|
|
734
745
|
return;
|
|
735
746
|
}
|
|
736
747
|
next();
|
|
737
748
|
}
|
|
738
|
-
function
|
|
749
|
+
function pathTraversalGuardPlugin() {
|
|
739
750
|
return {
|
|
740
|
-
name: "cms-
|
|
751
|
+
name: "cms-path-traversal-guard",
|
|
741
752
|
apply: "serve",
|
|
742
753
|
configureServer(server) {
|
|
743
|
-
server.middlewares.use(
|
|
754
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
744
755
|
}
|
|
745
756
|
};
|
|
746
757
|
}
|
|
@@ -1212,7 +1223,7 @@ function GlobalPartialSlot(props) {
|
|
|
1212
1223
|
}
|
|
1213
1224
|
);
|
|
1214
1225
|
}
|
|
1215
|
-
var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
|
|
1226
|
+
var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, MAX_EXTRA_DECODE_PASSES, hasTraversalSegment, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
|
|
1216
1227
|
var init_dist = __esm({
|
|
1217
1228
|
"../cms-js-internal/dist/index.js"() {
|
|
1218
1229
|
init_types_BWI07Ixv();
|
|
@@ -1320,6 +1331,8 @@ ${indentString}`);
|
|
|
1320
1331
|
prettyPrint
|
|
1321
1332
|
)}`;
|
|
1322
1333
|
};
|
|
1334
|
+
MAX_EXTRA_DECODE_PASSES = 3;
|
|
1335
|
+
hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
1323
1336
|
traverse = _traverse.default;
|
|
1324
1337
|
CMS_MODULE_COMPONENT_NAME = "Module";
|
|
1325
1338
|
DND_AREA_COMPONENT_NAME = "DndArea";
|
|
@@ -1448,7 +1461,7 @@ var main_default = {
|
|
|
1448
1461
|
postcss: webRoot
|
|
1449
1462
|
},
|
|
1450
1463
|
plugins: [
|
|
1451
|
-
|
|
1464
|
+
pathTraversalGuardPlugin(),
|
|
1452
1465
|
// Provide Node.js globals for browser environment
|
|
1453
1466
|
{
|
|
1454
1467
|
name: "provide-nodejs-globals",
|
|
@@ -199,34 +199,47 @@ function noncePlaceholderPlugin() {
|
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
var MAX_EXTRA_DECODE_PASSES = 3;
|
|
203
|
+
var hasTraversalSegment = (pathname) => pathname.split(/[/\\]/).includes("..");
|
|
204
|
+
function isPathTraversal(url2) {
|
|
203
205
|
if (!url2)
|
|
204
206
|
return false;
|
|
205
|
-
|
|
206
|
-
if (!pathname.endsWith(".map"))
|
|
207
|
-
return false;
|
|
208
|
-
let decodedPathname;
|
|
207
|
+
let decodedUrl;
|
|
209
208
|
try {
|
|
210
|
-
|
|
209
|
+
decodedUrl = decodeURI(url2);
|
|
211
210
|
} catch {
|
|
212
211
|
return true;
|
|
213
212
|
}
|
|
214
|
-
|
|
213
|
+
let [pathname] = decodedUrl.split(/[?#]/);
|
|
214
|
+
for (let pass = 0; pass < MAX_EXTRA_DECODE_PASSES; pass++) {
|
|
215
|
+
if (hasTraversalSegment(pathname))
|
|
216
|
+
return true;
|
|
217
|
+
let nextPathname;
|
|
218
|
+
try {
|
|
219
|
+
nextPathname = decodeURIComponent(pathname);
|
|
220
|
+
} catch {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
if (nextPathname === pathname)
|
|
224
|
+
return false;
|
|
225
|
+
pathname = nextPathname;
|
|
226
|
+
}
|
|
227
|
+
return hasTraversalSegment(pathname);
|
|
215
228
|
}
|
|
216
|
-
function
|
|
217
|
-
if (
|
|
229
|
+
function pathTraversalGuardMiddleware(req, res, next) {
|
|
230
|
+
if (isPathTraversal(req.url)) {
|
|
218
231
|
res.statusCode = 403;
|
|
219
232
|
res.end();
|
|
220
233
|
return;
|
|
221
234
|
}
|
|
222
235
|
next();
|
|
223
236
|
}
|
|
224
|
-
function
|
|
237
|
+
function pathTraversalGuardPlugin() {
|
|
225
238
|
return {
|
|
226
|
-
name: "cms-
|
|
239
|
+
name: "cms-path-traversal-guard",
|
|
227
240
|
apply: "serve",
|
|
228
241
|
configureServer(server) {
|
|
229
|
-
server.middlewares.use(
|
|
242
|
+
server.middlewares.use(pathTraversalGuardMiddleware);
|
|
230
243
|
}
|
|
231
244
|
};
|
|
232
245
|
}
|
|
@@ -781,7 +794,7 @@ async function forEachModule(projectRoot, moduleName, run) {
|
|
|
781
794
|
dedupe: ["react", "react-dom", "@hubspot/cms-components", "styled-jsx"]
|
|
782
795
|
},
|
|
783
796
|
plugins: [
|
|
784
|
-
|
|
797
|
+
pathTraversalGuardPlugin(),
|
|
785
798
|
react({
|
|
786
799
|
babel: {
|
|
787
800
|
plugins: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.86",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
31
|
"@babel/types": "^7.25.2",
|
|
32
|
-
"@hubspot/cms-components": "^1.2.
|
|
32
|
+
"@hubspot/cms-components": "^1.2.86",
|
|
33
33
|
"@hubspot/local-dev-lib": "5.15.0",
|
|
34
34
|
"@inquirer/select": "^2.0.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"cors": "^2.8.5",
|
|
61
61
|
"debug": "^4.3.4",
|
|
62
62
|
"dot-prop": "^9.0.0",
|
|
63
|
-
"express": "^4.
|
|
63
|
+
"express": "^4.22.3",
|
|
64
64
|
"findup-sync": "5.0.0",
|
|
65
65
|
"html-escaper": "^3.0.3",
|
|
66
66
|
"http-proxy-middleware": "^2.0.6",
|