Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval not in SAFE_GLOBALS #24

Open
matthewjh opened this issue May 2, 2024 · 2 comments
Open

eval not in SAFE_GLOBALS #24

matthewjh opened this issue May 2, 2024 · 2 comments

Comments

@matthewjh
Copy link

matthewjh commented May 2, 2024

Hi, nice library!

I had to use Function instead of eval, as the evaluator would throw eval is not defined. Indeed, eval is missing from the SAFE_GLOBALS list:

static get SAFE_GLOBALS() {
.

This is odd as the Readme file states eval is a "safe global" by default.

@matthewjh matthewjh changed the title eval not in SAFE_GLOBALS as docs state eval not in SAFE_GLOBALS May 2, 2024
@SimoTod
Copy link
Contributor

SimoTod commented May 2, 2024

It says the opposite. This library offers a safe alternative to eval. If you start using the native eval, you don't need this library.

@matthewjh
Copy link
Author

matthewjh commented May 2, 2024

I think you're missing my point. "eval" is listed as a global which is safely made available within the sandbox, along with Function ctor etc.. I'm talking about the symbols made available within the sandbox to the sandboxed code, which is what the list refers to, right?

I want to be able to safely execute code in the sandbox that itself uses eval. Function instead of eval works fine, so this appears to be a bug or oversight.

https://github.com/nyariv/SandboxJS?tab=readme-ov-file#safe-globals

Safe Globals

Function
eval
console
isFinite
isNaN
parseFloat
parseInt
decodeURI
decodeURIComponent
encodeURI
encodeURIComponent
escape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants