gpt4 book ai didi

ruby - 创建受 ruby 保护的环境

转载 作者:数据小太阳 更新时间:2023-10-29 07:56:58 24 4
gpt4 key购买 nike

虽然 ruby​​ 确实允许在代码的任何地方修改任何类,但我想知道是否有可能创建一个类似 protected 环境的沙箱来运行一些第三方代码,这样应用程序的其余部分代码将与任何任意代码隔离开来对预定义类/标准库类的修改。

最佳答案

您可以使用 Ruby 的安全级别:

http://www.ruby-doc.org/docs/ProgrammingRuby/html/taint.html

这里是安全等级4及以上的描述:

Ruby effectively partitions the running program in two. Nontainted objects may not be modified. Typically, this will be used to create a sandbox: the program sets up an environment using a lower $SAFE level, then resets $SAFE to 4 to prevent subsequent changes to that environment.

关于ruby - 创建受 ruby 保护的环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11014756/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com