Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I'd like to execute an untrusted js code using runInNewContext in node.js but as far as I see there is no way to limit its execution time. Also it is a sync operation. is there a way to set timeout on it or async version of it that will allow me to control its execution from 'outside'?</p> </blockquote> <p>I think What you are saying is completely true. I think the only option is to fill an issue with <a href="https://github.com/joyent/node/issues" rel="nofollow">Joyent/Ryan Dahl</a>. Hopefully he/they can come up with something smart or maybe will tell you it is not possible.</p> <p>From <a href="http://nodejs.org/docs/v0.4.9/api/all.html#vm.runInNewContext" rel="nofollow">vm.runInNewContext</a>:</p> <blockquote> <p>Note that running untrusted code is a tricky business requiring great care. To prevent accidental global variable leakage, vm.runInNewContext is quite useful, but safely running untrusted code requires a separate process.</p> </blockquote> <p>So to do this safely you need to run in external program. I think the "expensive part" can be avoided by <a href="http://httpd.apache.org/docs/2.0/mod/prefork.html#how-it-works" rel="nofollow">preforking</a>.</p> <blockquote> <p>A single control process is responsible for launching child processes which listen for connections and serve them when they arrive. Apache always tries to maintain several spare or idle server processes, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new child processes to be forked before their requests can be served.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload