寻找锁定的脚本跨preTER [英] Looking for a locked down script interpreter

查看:195
本文介绍了寻找锁定的脚本跨preTER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一个.NET库,做一个特定的任务。

I'm looking for a .NET library that does a specific task.

说我的应用程序已发送程序(在一些脚本语言),我想我的应用程序来运行该脚本。该脚本可以来自一个公开的敌对个人,但我想反正运行它。 (就像在JavaScript的浏览器。)

Say my app has been sent a program (in some script language) and I want my app to run that script. That script could come from an openly hostile individual, but I want to run it anyway. (Like JavaScript in a browser.)

var sc = new SecureScript("SomeFileFromAnUnknownPossiblyHostileSource.xyz");
/* Set some event handlers. */
sc.Run();

运行的电话,该脚本可以构建它自己的数据,乱用简单数据类型的身边,做任何事情,只要效果都包含在它自己的世界。

During the Run call, the script could construct it's own data, mess around with simple data types, do whatever it wants as long the effects are contained within it's own world.

如果脚本试图打开文件(C:/WINDOWS/SOMETHING.EXE),这将失败,因为我还没有注册的打开文件的功能。该脚本可以与外界交流的唯一方式是使用功能,我尤其对由脚本使用登记。通过这样做,我承担责任,该脚本不能用它做什么坏事。当然,我可以忽略验证的参数,但是这不是跨preTER的工作。

If the script attempts to OpenFile("C:/WINDOWS/SOMETHING.EXE"), that will fail, because I haven't registered an OpenFile function. The only way the script could interact with the outside world is by using a function I've especially registered for use by the script. By doing that, I'm taking responsibility that the script can't do anything bad with it. Sure, I could neglect to validate the parameters, but that's not the interpreter's job.

如果一个脚本分配太多的内存,或采取过多的CPU周期,跨preTER类将调用一旦门槛已经通过了我的事件处理程序,并给我停止脚本死者的力量。

If a script allocated too much memory, or take too many CPU cycles, the interpreter class would invoke my event handler once a threshold has been passed and give me the power to stop the script dead.

我更感兴趣的是跨preTER是安全的,而不是快。使用Javascript的JIT编译器都非常不错,但我听到的浏览器,由于我喜欢被更新,漏洞有点太频繁。

I'm more interested in the interpreter being secure rather than fast. Javascript JIT compilers are all very nice, but I hear of browsers being updated due to a vulnerability a bit too often for my liking.

所以,有我的请求。也许这已经存在或者我需要建立它自己。我想preFER一个.NET /单声道库,但我开到其他平台。

So, there's my plea. Maybe this already exists or I need to build it myself. I'd prefer a .NET/Mono library but I am open to other platforms.

非常感谢。

推荐答案

换句话说,你需要的沙箱的脚本的执行。

In other words, you need to sandbox the execution of your script.

有一个本地.NET机制,允许你这样做:AppDomain的权限

There is a native .NET mechanism which allows you to do that: AppDomain permissions.

看一看 如何:运行部分受信任的code。在一个沙箱

Have a look at How to: Run Partially Trusted Code in a Sandbox

然而,这是不够的,如果你想实现计算机资源的特定限制(内存和CPU)。可以说是一种简单的方式来运行你的code在有限的AppDomain,并限制计算机资源的消耗将是使用管理外接程序框架 ,特别是其 AddInProccess 类(请参阅管理加载项:高级版本和可靠的托管 机资源Exhaustions 部分)。

However, that will not be enough if you want to implement machine resource-specific restrictions (memory and CPU). An arguably simple way to run your code in a restricted AppDomain AND to limit machine resources consumption would be to use the Managed AddIn framework, and particularly its AddInProccess class (see Managing Add-Ins: Advanced Versioning and Reliable Hosting, Machine Resource Exhaustions section).

这篇关于寻找锁定的脚本跨preTER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆