Socket
Socket
Sign inDemoInstall

restrict

Package Overview
Dependencies
0
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    restrict

Restricts applications from calling certain methods on process and all methods on child_process


Version published
Weekly downloads
296
decreased by-16.85%
Maintainers
4
Install size
21.7 kB
Created
Weekly downloads
 

Readme

Source

restrict

Nodejs module that blocks applications from using procss.binding('process_wrap'), process.kill and child_process methods. This protects applications from invoking these methods unintentionally, that could harm the functioning of the framework or application being developed.

This package is tested only with Node versions 8 and 10.

install

With npm do:

npm install restrict

usage


var restrict = require('restrict');
// ls is whitelisted
restrict({
    'whitelist': ['ls'],
    'whitelistPath': ['/bin']
});

//set whitelist can be invoked, if the whitelist is dynamic
restrict.setWhitelist(['grep'], ['/bin', '/usr/bin']);

var child_process = require('child_process');
try {
    // ls is whitelisted. So you can see the output of ls
    child_process.exec('/bin/ls', function (err, stdout, stderr) {
        console.log(stdout);
    });
    // grep is not whitelisted. Exception thrown
    child_process.spawn('grep', ['ssh']);
} catch (e) {
    //this will throw an error
    //[Error: Function call spawn() is prohibited in this environment.]
    console.log(e);
}
try {
    process.kill(30);
} catch (e) {
    //this will throw an error
    //[Error: Function call process.kill() is prohibited in this environment.]
    console.log(e);
}

Build Status

Build Status

Node Badge

NPM

Keywords

FAQs

Last updated on 26 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc