mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-19 01:03:58 +00:00
fix(bots/discord): contextify object before sandboxing
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { unlinkSync, writeFileSync } from 'fs'
|
import { unlinkSync, writeFileSync } from 'fs'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { inspect } from 'util'
|
import { inspect } from 'util'
|
||||||
import { runInContext } from 'vm'
|
import { createContext, runInContext } from 'vm'
|
||||||
import { ApplicationCommandOptionType } from 'discord.js'
|
import { ApplicationCommandOptionType } from 'discord.js'
|
||||||
|
|
||||||
import { AdminCommand } from '$/classes/Command'
|
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
|
// to the bot while the bot is running, minus malicious actors getting the token to perform malicious actions
|
||||||
const output = await runInContext(
|
const output = await runInContext(
|
||||||
code,
|
code,
|
||||||
{
|
createContext({
|
||||||
...globalThis,
|
...globalThis,
|
||||||
context,
|
context,
|
||||||
},
|
}),
|
||||||
{
|
{
|
||||||
timeout: parseDuration(timeout ?? '10s'),
|
timeout: parseDuration(timeout ?? '10s'),
|
||||||
filename: 'eval',
|
filename: 'eval',
|
||||||
|
|||||||
Reference in New Issue
Block a user