-->

请问这个安全警告均值(.NET Process类)?(what does this security

2019-06-26 06:17发布

我使用VSTS 2008 + NET 2.0 + C#。 而且我编译后运行代码分析。 我得到了以下令人困惑的安全警告。 下面是警告和相关的代码,任何想法有什么不对吗? 如果有安全警告,如何解决呢?

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "IExplore.exe";
myProcess.StartInfo.Arguments = @"default.html";
myProcess.StartInfo.Verb = "runas";
myProcess.Start();

警告:CA2122:Microsoft.Security: 'TestHtml()' 调用到具有的LinkDemand '的Process.Start()'。 通过使该呼叫,“的Process.Start()”间接地暴露于用户的代码。 检查可能暴露的方式来规避安全保护下面的调用堆栈:

Answer 1:

你的方法调用美孚在调用其出于完全信任链接请求保护的的Process.Start。 为了避免这种情况的FxCop警告你这个问题,你应该添加了相同的权限,以你的方法链接请求或全部需求。

您可以通过添加到您的方法解决它

[PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")]

见http://msdn.microsoft.com/en-us/library/970x52db.aspx



Answer 2:

有关更多信息的安全警告和CA2122 -不要暴露间接地与链接请求方法



文章来源: what does this security warning mean (.Net Process class)?