nyariv/SandboxJS

Allowing all prototype methods

Closed this issue · 0 comments

Hello,

Thank you for this interesting library. I'm using it for a feature similar to stored procedures in my database strawberry-store. I have a question, not a bug:

I copied SAFE_GLOBALS and SAFE_PROTOTYPES from SandboxExec.ts and changed a few things. As it's written this code won't allow the following expression:

(1).toString()

On the prototype whitelist Number is an empty set like the default (see here link). Does this mean no prototype methods are permitted? Is there a way of allowing all prototype methods for a particular global or should I add them one-by-one like this:

prototypeWhitelist.set(Number, new Set([
  'toString',
  'toFixed',
  ...
]))