Use vm2 instead of sandbox library

This commit is contained in:
yoisahb5 2021-08-08 15:27:05 +02:00
parent 77a9c346d8
commit 0ac81b886e
2 changed files with 4 additions and 7 deletions

View File

@ -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

View File

@ -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) {}
},