RunSwift: Try Swift in Your Browser
runswiftlang.com
runswiftlang.com
I did a few things to get this running:
- The application server and build server are separate, with access control to the build server controlled by an API key that I can revoke should anyone gain access to it.
- The process that compiles and runs your code is an unprivileged user.
- All import statements are disabled in user submitted code
- Foundation is imported selectively with only a few classes allowed to be used by submitted code (namely, the NSString, NSArray, NSDictionary, etc APIs)
- Code is checked for a list of blacklisted APIs before hitting the compiler
- The execution of your code has a timeout of a few seconds, and the process will be killed should it take any longer.
I looked into more advanced techniques for sandboxing but couldn't find anything on OS X that was feasible. Happy to be schooled on security though, if you know better than I do :)
That said, the best, most foolproof way of doing this really comes down to using OS X to virtualize OS X.
Or you could try cross-compiling. It seems to work here: https://github.com/swift-x/tools (which looks interesting...)
It's possible that by the end of this week, maybe next, it will be very easy indeed to compile and/or run Swift on Linux from Linux, at which point you could try LXC or a million other ways to virtualize.
BTW we are running a Swift hackathon @ GitHub HQ in a few weeks, it would be cool if you could join us: http://www.swifthack.splashthat.com
And I would love to, but unfortunately I live on the other (better ;)) coast! Will you all be taping the talks?
I would like to see someone tackle this though.
Edit: Rolled back my changes; I'll sort them out when the server is a little busy :) Happy Saturday!