Ruby 脚本引擎?

发布于 2024-08-28 04:23:15 字数 435 浏览 3 评论 0原文

我正在创建一个 Ruby On Rails 网站,一方面它需要是动态的,以便(某种)受信任的用户可以使网站的某些部分以不同的方式工作。为此,我需要一种脚本语言。在 ASP.Net 的一个类似项目中,我编写了自己的脚本语言/DSL。不过,我无法使用该源代码(在工作中编写),并且如果不需要,我也不想制作另一种脚本语言。

那么,我有什么选择呢?脚本必须被锁定,并且不能使我的服务器或任何东西崩溃。我真的很希望能够使用 Ruby 作为脚本语言,但这并不是绝对必要的。此外,几乎每次对网站的请求都会调用此脚本部分,有时甚至不止一次。所以,速度是一个因素。

我查看了 RubyLuaBridge,但它处于 Alpha 状态并且似乎已经死了。

在 Ruby 项目中我可以选择哪些脚本语言?

此外,我将完全控制该项目的部署位置(root 访问权限),因此没有真正的限制。

I am creating a Ruby On Rails website, and for one part it needs to be dynamic so that (sorta) trusted users can make parts of the website work differently. For this, I need a scripting language. In a sort of similar project in ASP.Net, I wrote my own scripting language/DSL. I can not use that source code(written at work) though, and I don't want to make another scripting language if I don't have to.

So, what choices do I have? The scripting must be locked down and not be able to crash my server or anything. I'd really like if I could use Ruby as the scripting language, but it's not strictly necessary. Also, this scripting part will be called on almost every request for the website, sometimes more than once. So, speed is a factor.

I looked at the RubyLuaBridge but it is Alpha status and seems dead.

What choices for a scripting language do I have in a Ruby project?

Also, I will have full control over where this project is deployed(root access), so there are no real limits..

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

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

发布评论

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

评论(3

倾城月光淡如水﹏ 2024-09-04 04:23:15

还有 Rufus-lua,尽管它的版本是 0.1。 0...

There's also Rufus-lua though it's at version 0.1.0...

很酷不放纵 2024-09-04 04:23:15

JRuby 怎么样?您可以使用许多脚本语言的java实现,例如javascript、scheme等

What about JRuby? You can use java implementation of many scripting language, such as javascript, scheme etc

嘿哥们儿 2024-09-04 04:23:15

好吧,既然还没有建议,那就有将 Ruby 锁在保险箱中< /a> 如镐书所述。这允许您使用 Ruby 作为语言,据我所知不会显着减慢速度。

这种技术的目的是允许对不受信任的 Ruby 代码进行安全沙箱处理,并且错误修复和讨论都是为了保持这种方式,但无限循环和其他一些事情仍然允许恶意用户锁定 CPU。 (例如,这个讨论可能。 )

我不知道的是如何从安全线程外部返回本质上安全的数据。单例对象(例如)可以模仿任何类,然后在返回线程中调用任何方法时执行一些危险的操作。我仍在谷歌上搜索它。 (Ruby 编程语言说第 4 级“防止元编程方法”将允许您安全地验证返回对象的类,我认为这将使结果可以安全使用。)

除此之外,这可能并不难(*snrk *) 实现具有动态作用域的 Lisp-1,因为您已经有了垃圾收集器。

Well, since it hasn't been suggested yet, there's Locking Ruby In The Safe as described by the Pickaxe book. This allows you to use Ruby as the language without significant slowdown AFAIK.

This technique is intended to allow safe sandboxing of untrusted Ruby code and bug fixes and discussions are directed toward keeping it that way, but infinite loops and some other things still allow malicious users to peg the CPU. (e.g. this discussion maybe.)

What I don't know is how you return data that is inherently safe to use from outside the safe thread. A singleton object (for instance) can mimic whatever class and then do something dangerous when any method is called in the returning thread. I'm still googling around about it. (The Ruby Programming Language says that level 4 "Prevents metaprogramming methods" which would allow you to safely verify the class of a returned object, which I suppose would make results safe to use.)

Barring that, it might not be hard (*snrk*) to implement a Lisp-1 with dynamic scope since you already have a garbage collector.

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