| 4 | const fs = require('fs'); |
| 5 | |
| 6 | class DefaultFileSystem { |
| 7 | |
| 8 | resolve(path) { |
| 9 | return pa.resolve(path); |
| 10 | } |
| 11 | |
| 12 | // SECURITY: Dereferences symlinks before path-prefix root checks. |
| 13 | // Without this, an attacker can place a symlink inside `require.root` |
| 14 | // pointing outside it; the lexical resolve() passes the prefix check |
| 15 | // while Node's native require() follows the symlink. See GHSA-cp6g-6699-wx9c. |
| 16 | realpath(path) { |
| 17 | return fs.realpathSync(path); |
| 18 | } |
| 19 | |
| 20 | isSeparator(char) { |
| 21 | return char === '/' || char === pa.sep; |
| 22 | } |
| 23 | |
| 24 | isAbsolute(path) { |
| 25 | return pa.isAbsolute(path); |
| 26 | } |
| 27 | |
| 28 | join(...paths) { |
| 29 | return pa.join(...paths); |
| 30 | } |
| 31 | |
| 32 | basename(path) { |
| 33 | return pa.basename(path); |
| 34 | } |
| 35 | |
| 36 | dirname(path) { |
| 37 | return pa.dirname(path); |
| 38 | } |
| 39 | |
| 40 | statSync(path, options) { |
| 41 | return fs.statSync(path, options); |
| 42 | } |
| 43 | |
| 44 | readFileSync(path, options) { |
| 45 | return fs.readFileSync(path, options); |
| 46 | } |
| 47 | |
| 48 | } |
| 49 | |
| 50 | class VMFileSystem { |
| 51 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…