Hacker News new | ask | show | jobs
by _RPM 3716 days ago
"safe eval". What does that even mean?
1 comments

"safe-eval lets you execute JavaScript code without having to use the much discouraged and feared upon eval(). safe-eval has access to all the standard JavaScript API of the underlying engine. It is implemented using node's vm module." [1]

[1] https://www.npmjs.com/package/safe-eval

It's important to note that running code in vm.runInNewContext is not advised for 'untrusted code' according to the documentation. So probably not good to let random people use this bot.

"script.runInNewContext() is quite useful, but safely running untrusted code requires a separate process."[0]

[0] - https://nodejs.org/api/vm.html#vm_script_runinnewcontext_san...

https://github.com/hacksparrow/safe-eval/blob/master/index.j...

Maybe it's not a nice idea to use Math.random for secure and unique keys.