3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00

use sandbox module for running untrusted code because it has a timeout

This commit is contained in:
Luke Slater 2012-02-13 20:11:51 +00:00
parent d72d5f5bdc
commit 9b1fd7aa4e
2 changed files with 6 additions and 2 deletions

View File

@ -37,7 +37,7 @@ var adminCommands = function(dbot) {
'unload': function(data, params) {
if(dbot.moduleNames.include(params[1])) {
dbot.moduleNames[params[1]] = undefined;
delete dbot.moduleNames[params[1]];
dbot.reloadModules();
dbot.say(data.channel, 'Turned off module: ' + params[1]);
} else {

View File

@ -1,12 +1,16 @@
var vm = require('vm');
var sandbox = require('sandbox');
var js = function(dbot) {
var dbot = dbot;
var s = new Sandbox();
var commands = {
'~js': function(data, params) {
var q = data.message.valMatch(/^~js (.*)/, 2);
dbot.say(data.channel, vm.runInNewContext(q[1]));
s.run(q[1], function(output) {
dbot.say(data.channel, output.result);
});
},
'~ajs': function(data, params) {