Web 浏览器中的 Ruby

发布于 2024-12-27 17:05:17 字数 176 浏览 4 评论 0原文

我正在寻找下一个问题的解决方案:现在我正在开发一个 Rails 应用程序。我希望能够在浏览器中使用 Ruby 进行编码,然后在我的 Rails 应用程序中执行该代码。

有一些现成的解决方案吗?

UPD:

  1. 代码突出显示怎么样?
  2. 本地客户端怎么样?

I'm looking for some solution of next problem: Now i'm developing an Rails app. I want to have possibility to code in Ruby at browser and then execute that code in my Rails app.

Are there some ready solutions?

UPD:

  1. what about code highlighting?
  2. what about Native Client?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烛影斜 2025-01-03 17:05:17

https://github.com/codegram/rack-webconsole

或者你可以简单地传递 Ruby 代码通过 post 发送到服务器并调用 eval 评估(代码)

您应该注意,尤其是第二种方式非常不安全,因为它使执行代码可以完全访问您的系统。

如果确实必须这样做,“将 Ruby 锁定在保险箱中”可以帮助确保安全它。

编辑:

对于语法突出显示,请查看 Code MirrorACE.两者都是不错的源代码编辑器,支持 ruby​​。

https://github.com/codegram/rack-webconsole

Or you could simply pass the Ruby code to the server via post and call eval eval(CODE).

You should note that especially the second way is very insecure since it gives the executing code complete access to your system.

If this really has to be done "Locking Ruby in the Safe" could help secure it.

EDIT:

For syntax highlighting take a look at Code Mirror and ACE. Both are decent source code editors with ruby support.

白昼 2025-01-03 17:05:17

目前还没有任何实际的可部署解决方案,但您可以查看 text/x-ruby 作为概念证明。

还有 Cloud9 IDE,它充当基于浏览器的 IDE,并将代码保留回服务器以供运行。

There aren't really any real-world deployable solutions for this yet, but you might look at text/x-ruby as a proof of concept.

There's also the Cloud9 IDE which functions as a browser-based IDE, and will persist code back to your server to be run.

じ违心 2025-01-03 17:05:17

eval 就是您要寻找的内容。用户输入 Ruby 代码,该代码会发布到您的 Rails 应用程序。在控制器内,您需要评估提交的 Ruby 代码。

但。你可能不想要这个。如果确实需要评估和运行用户提交的代码,您很可能需要重新考虑对该功能的需求。这几乎不可能保证安全。即使您保护它免受某些用户的攻击,它也可能通过 XSS 被利用;通过这个“功能”,它实际上可以立即接管服务器。

eval is what you are looking for. A user enters Ruby-code, which gets POSTed to your rails app. Inside your controller you will need to eval the submitted Ruby code.

But. You probably don't want this. If there really seems to be a need to evaluate and run user submitted code, you most probably will need to re-think the need for that feature. This is almost impossible to make secure. And even when you secure it from certain users, it can be exploited trough XSS; which can actually take over a server in no-time trough this "feature".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文