限制某些函数被调用的替代方法?
Alternative ways to restricting certain functions being called?
我最近了解到 AppDomain
在 .NET Core 中没有得到完全支持,他们目前还没有实施全面支持的计划。
我想做的是制作一个可以 运行 插件的程序,但我不希望该插件能够访问某些程序集或名称空间(例如 System.IO
).
.NET Core 之前的 way I used to solve this problem 由于缺乏支持将不再有效。
有没有其他方法可以在 .NET Core 中实现相同的目的?
更具体的例子
假设我使用 Assembly.LoadFrom
从文件系统加载一个程序集,其中包含一个我随后调用的插件方法。但是我不希望插件能够擦除文件等等。实际上,我只希望插件能够调用特定程序集中的函数。
基本上,他们希望您针对您正在开发的环境使用平台边界。
Sandboxing
Why was it discontinued?
Sandboxing, i.e. relying on the runtime or the framework to constrain which resources a managed application can access, is considered a non-goal for .NET Core. Sandboxing applications and components is also really hard to get right, which is why generally recommend customers not to rely on it. It also makes the implementation more complicated and often negatively affects performance of applications that don’t use sandboxing. Hence, we do not offer sandboxing features in .NET Core.
What should I use instead?
Use operating system provided security boundaries, such as user accounts for running processes with the least set of privileges.
https://blogs.msdn.microsoft.com/dotnet/2016/02/10/porting-to-net-core/
我最近了解到 AppDomain
在 .NET Core 中没有得到完全支持,他们目前还没有实施全面支持的计划。
我想做的是制作一个可以 运行 插件的程序,但我不希望该插件能够访问某些程序集或名称空间(例如 System.IO
).
.NET Core 之前的 way I used to solve this problem 由于缺乏支持将不再有效。
有没有其他方法可以在 .NET Core 中实现相同的目的?
更具体的例子
假设我使用 Assembly.LoadFrom
从文件系统加载一个程序集,其中包含一个我随后调用的插件方法。但是我不希望插件能够擦除文件等等。实际上,我只希望插件能够调用特定程序集中的函数。
基本上,他们希望您针对您正在开发的环境使用平台边界。
Sandboxing
Why was it discontinued?
Sandboxing, i.e. relying on the runtime or the framework to constrain which resources a managed application can access, is considered a non-goal for .NET Core. Sandboxing applications and components is also really hard to get right, which is why generally recommend customers not to rely on it. It also makes the implementation more complicated and often negatively affects performance of applications that don’t use sandboxing. Hence, we do not offer sandboxing features in .NET Core.
What should I use instead?
Use operating system provided security boundaries, such as user accounts for running processes with the least set of privileges.
https://blogs.msdn.microsoft.com/dotnet/2016/02/10/porting-to-net-core/