具有托管扩展性框架的沙箱插件
我正在开发一个应用程序,第三方开发人员可以在其中编写插件。我一直在研究托管可扩展性框架,这似乎是正确的方法。
但有一件事,我想阻止插件自由访问应用程序的其余部分(调用单例等),但希望限制为通过某些接口进行通信,理想情况下每个插件都必须“请求”不同事物的权限,例如访问其他插件插件和用户数据,有什么好方法来实现这一点吗?
我唯一能想到的就是将安全字符串传递给每个方法并混淆代码,但这似乎是一个丑陋的解决方案:P
I'm working on an application where third party developers will be able to write plugins. I've been looking a little at Managed Extensibility Framework and it seems the right way to go.
One thing though, I want to prevent plugins from accessing the rest of the application freely (calling singletons etc) but would want to restrict to to communicate via some interface, ideally each plugin would have to "request" permission for different things like accessing other plugins and user data, is there a good way to do accomplish this?
Only thing I can think of otherwise is to have a security string passed to each method and obfuscate the hell out of the code but it seems like an ugly solution :P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要的是一个新的
AppDomain
作为您的插件的沙箱,但我认为 MEF 目前不支持将导出加载到单独的AppDomain
中(我确信如果不再是这种情况,有人会纠正我)。如果这对您来说是一个严重的问题,请考虑使用
中的位System.Addin
命名空间,请参阅 激活、隔离、安全性和沙盒了解更多信息。它是 MEF 的更强大、更安全的替代方案,但灵活性却差得多。更新:Kent Boogaart 有一篇博客文章< /a> 展示如何一起使用 MEF 和 MAF。
What you need is a new
AppDomain
to be the sandbox for your plugin, but I don't think MEF supports loading exports into a separateAppDomain
at this time (I'm sure someone will correct me if this is no longer the case).If this is a serious concern for you, consider using the bits in the
System.Addin
namespace, and see this section on Activation, Isolation, Security, and Sandboxing for more information. It's a much more robust and secure alternative to MEF, but is far less flexible.Update: Kent Boogaart has a blog post showing how you can use MEF and MAF together.