mirror of
https://github.com/reality/dbot.git
synced 2024-12-26 04:32:37 +01:00
Merge pull request #690 from yoisahb5/js-vm2
Use vm2 instead of sandbox library
This commit is contained in:
commit
7d9a9eeeff
2
install
2
install
@ -14,7 +14,7 @@ if [[ $? -gt 0 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npm install googlemaps humanize feedparser node-units tvdb method-override 500px process async wordnik node-uuid underscore request request-promise-native sandbox express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash
|
npm install googlemaps humanize feedparser node-units tvdb method-override 500px process async wordnik node-uuid underscore request request-promise-native vm2 express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash
|
||||||
|
|
||||||
cd public/
|
cd public/
|
||||||
wget https://github.com/twbs/bootstrap/releases/download/v3.3.2/bootstrap-3.3.2-dist.zip
|
wget https://github.com/twbs/bootstrap/releases/download/v3.3.2/bootstrap-3.3.2-dist.zip
|
||||||
|
@ -4,18 +4,15 @@
|
|||||||
* the channel. Also allows admins to run un-sandboxed Javascript code with
|
* the channel. Also allows admins to run un-sandboxed Javascript code with
|
||||||
* access to the DepressionBot instance memory.
|
* access to the DepressionBot instance memory.
|
||||||
*/
|
*/
|
||||||
var vm = require('vm');
|
var VM = require('vm2').VM;
|
||||||
var sbox = require('sandbox');
|
|
||||||
|
|
||||||
var js = function(dbot) {
|
var js = function(dbot) {
|
||||||
var commands = {
|
var commands = {
|
||||||
// Run JS code sandboxed, return result to channel.
|
// Run JS code sandboxed, return result to channel.
|
||||||
'~js': function(event) {
|
'~js': function(event) {
|
||||||
try {
|
try {
|
||||||
var s = new sbox();
|
var s = new VM({timeout: 1000, sandbox: {}});
|
||||||
s.run(event.input[1], function(output) {
|
event.reply(s.run(code));
|
||||||
event.reply(output.result);
|
|
||||||
}.bind(this));
|
|
||||||
} catch(err) {}
|
} catch(err) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user