Search code examples
rubysandbox

Preventing filesystem access and other destructive actions


I would like to create a small Rails application that would allow users to give a few snippets of code to benchmark in multiple implementations and versions of Ruby. I am capable of creating the application, I am just afraid of users mucking around in the filesystem or doing other destructive actions. Is there any way to prevent this?


Solution

  • There is $SAFE:

    The variable $SAFE determines Ruby's level of paranoia.

    The various "safety levels" are noted at the link, there's also some examples (which still work) of using a thread, $SAFE, and load to wrap untrusted code. $SAFE on ruby might be worth a look as well.