Module basic module

Module vm

Security sandbox module, used to isolate operating environments of different security levels

By establishing a security sandbox, you can limit the resources that can be accessed during script execution, isolate different script execution environments, and customize basic modules for different environments to ensure the security of the overall operating environment.

The following example creates a sandbox and restricts access to the global basic module assert Module, and add two custom modules, a and b:

1 2 3 4 5 6 7 8
var vm = require('vm'); var sbox = new vm.SandBox({ a: 100, b: 200, assert: require('assert') }); var mod_in_sbox = sbox.require('./path/to/mod');



Create SandBox Object, see SandBox

SandBox vm.SandBox;