Fix jsRunner.spec.ts.

This commit is contained in:
Sam Rose 2024-10-03 13:11:01 +01:00
parent df242cc2ad
commit f9ccbbe081
No known key found for this signature in database
3 changed files with 6 additions and 5 deletions

View File

@ -41,10 +41,11 @@ describe("jsRunner (using isolated-vm)", () => {
})
it("should prevent sandbox escape", async () => {
const output = await processJS(
`return this.constructor.constructor("return process.env")()`
await expect(
processJS(`return this.constructor.constructor("return process.env")()`)
).rejects.toThrow(
"error while running user-supplied JavaScript: ReferenceError: process is not defined"
)
expect(output).toBe("ReferenceError: process is not defined")
})
describe("helpers", () => {

View File

@ -22,7 +22,7 @@ class UserScriptError extends Error {
code = "USER_SCRIPT_ERROR"
constructor(readonly userScriptError: Error) {
super(
`error while running user-supplied JavaScript: ${userScriptError.message}`,
`error while running user-supplied JavaScript: ${userScriptError.toString()}`,
{ cause: userScriptError }
)
}

View File

@ -7,7 +7,7 @@ export class UserScriptError extends Error {
constructor(readonly userScriptError: Error) {
super(
`error while running user-supplied JavaScript: ${userScriptError.message}`
`error while running user-supplied JavaScript: ${userScriptError.toString()}`
)
}
}