3
0
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:
reality 2021-09-22 12:53:33 +01:00 committed by GitHub
commit 7d9a9eeeff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {}
},