gpt4 book ai didi

c# - SecurityPermission 和 SecurityPermissionFlag.SkipVerification 的后果

转载 作者:太空宇宙 更新时间:2023-11-03 16:17:57 25 4
gpt4 key购买 nike

在 MSDN 文档中,SecurityPermissionFlag.SkipVerification说:

Ability to skip verification of code in this assembly. Code that is unverifiable can be run if this permission is granted.

This is a powerful permission that should be granted only to highly trusted code.

This flag has no effect when used dynamically with stack modifiers such as Deny, Assert, and PermitOnly.

我目前正在开发的一些项目要求我使用 SkipVerificationFlag。具体案例是一些自定义类使用 CaSTLe Windsor 创建控制反转组件的实例,因为调用整个方法的程序集不是完全可信的

这可能是中的伪代码对于带有 SkipVerification 的方法:

[SecuritySafeCritical]
[ReflectionPermission(SecurityAction.Assert, Unrestricted = true)]
[SecurityPermission(SecurityAction.Assert, SkipVerification = true)]
public override TComponent Resolve<TComponent>(string id = null, bool release = true, object argumentsAsAnonymousObject = null)
{
// Some stuff...
windsorContainer.Resolve<TComponent>(...);
}

CaSTLe Windsor 程序集在 AppDomain 中完全受信任。

所以问题是...

如果我认为我只相信 CaSTLe Windsor 代码而仅此而已,那我错了吗?

上述伪代码的消费者/调用者处于不受信任(非完全信任)AppDomain 中。或者换句话说:使用该门的第三方代码是安全透明的。

在我看来,由于温莎城堡不会做危险的事情,因此使用整面旗帜是安全的

我的决定在安全方面的后果是什么?

谢谢。

最佳答案

据我所知,根据可用信息,断言 SkipValidation 似乎没有其他后果。

如果您可以完全依赖在关键部分内执行的代码,它可以被视为安全代码,因此 CaSTLe Windsor(或任何其他受信任的代码)没有问题。

关于c# - SecurityPermission 和 SecurityPermissionFlag.SkipVerification 的后果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15120670/

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