Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I sandbox Clojure?

Tags:

clojure

I am writing an application which allow users of my application to extend it using Clojure. The Clojure is entered via a web page in the application and "evaled" to run. My question is how can I sandbox this code entered by the users so that it does not corrupt anything or call System.exit or anything like that?

like image 340
yazz.com Avatar asked Mar 10 '11 10:03

yazz.com


2 Answers

There's a library for that. lazybot in the Clojure IRC chanel uses it. You can find it here: https://github.com/flatland/clojail

like image 139
Marten Veldthuis Avatar answered Oct 17 '22 20:10

Marten Veldthuis


You should be able to constrain access to code by configuring JDK level permissions. Have a look at the RuntimePermission settings, there's for example a direct setting to inhibit halting the JVM (e.g. System.exit).

like image 3
skuro Avatar answered Oct 17 '22 20:10

skuro