Prevent imports of unauthorized classes in Scala -


i'm working on online environment allow users execute custom scala code (think of continuous integration). however, want prevent them doing things, notably file i/o , network calls. allow limited forms of these functions library expose.

the naive approach replace /^import.*$/ empty string. however, there plenty of ways nefarious folks around that, classloaders , such. want users have access preselected "whitelist" of imports rather having rely on (possibly incomplete) blacklist.

i still haven't decided whether i'm going call scalac on underlying os files, or whether use imain interpret text. if 1 method makes desired result feasible, i'll go one. bonus points if answer includes ways

how can sandbox users' code?

there 2 different issues: compile-time , run-time sandboxing.

runtime sandboxing can accomplished using java security , classloader restrictions - see e.g. how create java sandbox? and, more cautionary, can trust java securitymanager sandbox?. there's lot more out there on topic!

for scala compile-time sandboxing, have defer. however, wonder whether need it. if people try use forbidden api's trying break system, there's no reason make job easier providing compile-time checking.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -