tags:

views:

225

answers:

4

Im wondering how to go about creating an online IRB that runs in the browser. I have an idea to include an irb console in my blog and give the option for users to send code blocks in my tutorials directly into the irb console so they can play around with it.

_Why did this previously, but of course it is gone now: Cached Version

+1  A: 

That's insanely dangerous. Don't do this. You expose your system to all sorts of vulnerabilities when you allow users to execute arbitrary Ruby code.

Anyway there are some client-side Ruby implementations in JavaScript/Flash. Take a look at HotRuby.

Wahnfrieden
Dude, calm down. I don't think he's planning to run his online IRB unsandboxed on his accounting records server.
Chuck
Even a sandboxed IRB on your server is questionable to me. If you're going to implement this, you need to really stay on top of security updates and things like that.
Wahnfrieden
This is much less risk than your average Web host takes on, and nobody says, "OMG, don't host Web sites! You'll expose your system to all sorts of vulnerabilities!"
Chuck
Apparently _why's script was found to have security vulnerabilities.
Wahnfrieden
What? It gives out your social security number?
Chuck
If you think data access is the only concern with security, you've got a lot to learn...
Wahnfrieden
Additionally, if he has to ask about this, I doubt he knows well enough how to sandbox and protect his server for securely running untrusted code.
Wahnfrieden
Again, is it more dangerous than allowing people to host dynamic Web sites on your server?
Chuck
A: 

I would suspect you run Ruby in a sandbox to prevent "bad" commands being run.

Kris
+2  A: 

Well, you could use the sandbox that _why created. But you'll need to be able to patch your ruby and it seems to only work on ruby 1.8.5 .

Thanks didn't know this code was still publicaly available.
Corban Brook
It apparently has security vulnerabilities.
Wahnfrieden
+3  A: 

TryRuby is still available here, with source code at GitHub.

UPDATE: That TryRuby implementation isn't actually working at the moment, apparently due to security concerns. But hopefully you'll be able to learn something from the code.

Martin Owen