mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 11:42:36 +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
|
||||
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/
|
||||
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
|
||||
* access to the DepressionBot instance memory.
|
||||
*/
|
||||
var vm = require('vm');
|
||||
var sbox = require('sandbox');
|
||||
var VM = require('vm2').VM;
|
||||
|
||||
var js = function(dbot) {
|
||||
var commands = {
|
||||
// Run JS code sandboxed, return result to channel.
|
||||
'~js': function(event) {
|
||||
try {
|
||||
var s = new sbox();
|
||||
s.run(event.input[1], function(output) {
|
||||
event.reply(output.result);
|
||||
}.bind(this));
|
||||
var s = new VM({timeout: 1000, sandbox: {}});
|
||||
event.reply(s.run(code));
|
||||
} catch(err) {}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user