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, restricts access to only the assert module in the global base module, and adds 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');

Object

SandBox

Create a SandBox object, see SandBox

1
SandBox vm.SandBox;