New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

restrict

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restrict - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

6

lib/index.js

@@ -55,3 +55,3 @@ /*

paths = (paths instanceof Array) ? paths : [paths];
this.commandPaths = getPathCombinations(commands, paths);
this.commandPaths = getPathCombinations(this.commands, paths);
};

@@ -145,4 +145,4 @@

module.exports = restrict;
module.exports.setWhitelist = function() {
whitelist.set(arguments);
module.exports.setWhitelist = function(commands, paths) {
whitelist.set(commands, paths);
};
{
"name": "restrict",
"description": "Restricts applications from calling certain methods on process and all methods on child_process",
"version": "0.0.5",
"version": "0.0.6",
"author": "Rohini Harendra <rohini.raghav@gmail.com>",

@@ -6,0 +6,0 @@ "repository": {

@@ -162,5 +162,6 @@ /*

var self = this;
restrict.setWhitelist(['grep'], ['/bin', '/usr/bin']);
try {
restrict.setWhitelist(['grep'], ['/bin', '/usr/bin']);
require('child_process').spawn('grep',['BLA', './*']);
self.callback(null, {});
} catch (e) {

@@ -176,2 +177,36 @@ self.callback(null, {

},
'testing restrict with setWhitelist child_process methods whitelist with full path': {
topic: function () {
var self = this;
try {
restrict.setWhitelist(['grep'], ['/bin', '/usr/bin']);
require('child_process').spawn('/usr/bin/grep',['BLA', './*']);
self.callback(null, {});
} catch (e) {
self.callback(null, {
'error': e
});
}
},
'verify error': function (topic) {
assert.ok(topic.error === undefined);
}
},
'testing restrict with setWhitelist child_process methods whitelist with not whitelist path': {
topic: function () {
var self = this;
try {
restrict.setWhitelist(['grep'], ['/bin', '/usr/bin']);
require('child_process').spawn('/usr/bin64/grep',['BLA', './*']);
self.callback(null, {});
} catch (e) {
self.callback(null, {
'error': e
});
}
},
'verify error': function (topic) {
assert.ok(topic.error);
}
},
'testing restrict with setWhitelist child_process methods non-whitelist': {

@@ -189,3 +224,2 @@ topic: function () {

}
},

@@ -196,4 +230,28 @@ 'verify error': function (topic) {

},
'testing restrict with setWhitelist with not arguments child_process methods non-whitelist': {
topic: function () {
var self = this;
try {
restrict.setWhitelist();
} catch(e) {
self.callback(null, {
'error1': e
});
}
try {
require('child_process').exec('ls',['-ltr']);
self.callback(null, {});
} catch (e) {
self.callback(null, {
'error2': e
});
}
},
'verify error': function (topic) {
assert.ok(topic.error1 === undefined);
assert.ok(topic.error2 !== null);
}
},
}
vows.describe('restrict').addBatch(tests).addBatch(tests_next).export(module);
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc