mirror of
https://github.com/vitejs/vite.git
synced 2026-10-28 08:25:27 +08:00
fix(wasm): reject .wasm outside server.fs (#23914)
This commit is contained in:
5 files changed
+16
No files matched your search
@@ -53,6 +53,7 @@ const urlRE = /[?&]url\b/
|
||||
const rawRE = /[?&]raw\b/
|
||||
const inlineRE = /[?&]inline\b/
|
||||
const svgRE = /\.svg\b/
|
||||
const wasmRE = /(?<![?#].*)\.wasm$/
|
||||
const wasmInstanceRE = /[?&]vite-wasm-instance(?:&|$)/
|
||||
|
||||
export function isServerAccessDeniedForTransform(
|
||||
@@ -64,6 +65,7 @@ export function isServerAccessDeniedForTransform(
|
||||
urlRE.test(id) ||
|
||||
inlineRE.test(id) ||
|
||||
svgRE.test(id) ||
|
||||
wasmRE.test(id) ||
|
||||
wasmInstanceRE.test(id)
|
||||
) {
|
||||
return (
|
||||
|
||||
@@ -127,6 +127,13 @@ export function tests() {
|
||||
disableVariants: [''],
|
||||
},
|
||||
|
||||
{
|
||||
name: 'unsafe WASM import',
|
||||
testId: 'unsafe-wasm-import',
|
||||
content: /403 Restricted/,
|
||||
status: '403',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'unsafe fetch',
|
||||
testId: 'unsafe',
|
||||
|
||||
@@ -9,6 +9,7 @@ const testIds = [
|
||||
'safe-subdir-special-characters2',
|
||||
'safe-imported',
|
||||
'safe-imported-query',
|
||||
'unsafe-wasm-import',
|
||||
'unsafe',
|
||||
'unsafe-json',
|
||||
'unsafe-html',
|
||||
|
||||
@@ -83,6 +83,11 @@
|
||||
// imported before with query
|
||||
{ testId: 'safe-imported-query', path: '/safe.json?query' },
|
||||
|
||||
{
|
||||
testId: 'unsafe-wasm-import',
|
||||
path: '/root/unsafe.wasm?import',
|
||||
},
|
||||
|
||||
// outside of allowed dir
|
||||
{ testId: 'unsafe', path: '/root/unsafe.txt' },
|
||||
// outside of allowed dir and root
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
KEY=unsafe
|
||||
Reference in new issue
Block a user