MCPcopy
hub / github.com/patriksimek/vm2 / DefaultFileSystem

Class DefaultFileSystem

lib/filesystem.js:6–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4const fs = require('fs');
5
6class 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
50class VMFileSystem {
51

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…