From 062735f6d552890404d6192244c51a11b0709580 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Wed, 25 Sep 2024 12:49:08 +0700 Subject: [PATCH] fix(bots/discord): contextify object before sandboxing --- bots/discord/src/commands/admin/eval.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bots/discord/src/commands/admin/eval.ts b/bots/discord/src/commands/admin/eval.ts index 3aab45d..5e2b282 100644 --- a/bots/discord/src/commands/admin/eval.ts +++ b/bots/discord/src/commands/admin/eval.ts @@ -1,7 +1,7 @@ import { unlinkSync, writeFileSync } from 'fs' import { join } from 'path' import { inspect } from 'util' -import { runInContext } from 'vm' +import { createContext, runInContext } from 'vm' import { ApplicationCommandOptionType } from 'discord.js' import { AdminCommand } from '$/classes/Command' @@ -43,10 +43,10 @@ export default new AdminCommand({ // to the bot while the bot is running, minus malicious actors getting the token to perform malicious actions const output = await runInContext( code, - { + createContext({ ...globalThis, context, - }, + }), { timeout: parseDuration(timeout ?? '10s'), filename: 'eval',