1.0.1 • Published 8 years ago
ghost-sandbox v1.0.1
Ghost Sandbox
This module was extracted from the Ghost blogging platform project. Its sole purpose is to create a sandboxed environment for Node.js modules.
Installation
npm install ghost-sandbox
Example 1: Using a whitelist
Using a whitelist
will only allow the the sandboxed module to require the listed modules.
"use strict";
const Sandbox = require('ghost-sandbox');
const sandbox = new Sandbox({
whitelist: ['when', 'lodash', ...]
});
const sandboxedModule = sandbox.loadWidget(modulePath);
Example 2: Using a blacklist
Using a blacklist
will only reject the listed modules.
"use strict";
const Sandbox = require('ghost-sandbox');
const sandbox = new Sandbox({
blacklist: ['path', 'fs', ...]
});
const sandboxedModule = sandbox.loadWidget(modulePath);
Note: If you include both options, the whitelist
will supersede the blacklist
.
Test
npm test
Change log
v1.0.1
- Fixed logical error when loading modules
- Updated README
v1.0.0
- Removed lodash as dependency
v0.1.1
- Updated code to ES6
v0.1.0
First version
License
(MIT License)