CS.SV.LINK_DEMAND.INHERITANCE
Type link demands require inheritance demands.
A link demand on a method or its declaring type requires the immediate caller of the method to have the specified permission. An inheritance demand on a method requires an overriding method to have the specified permission. An inheritance demand on a type requires a deriving class to have the specified permission.
Mitigation and prevention
To fix a violation of this rule, secure the type or the method with an inheritance demand for the same permission as the link demand.
Vulnerable code example
2 using System; 3 using System.Security.Permissions; 4 5 namespace SecurityLibrary 6 { 7 [EnvironmentPermission(SecurityAction.LinkDemand, Read = "PATH")] 8 public class TypesWithLinkDemands 9 { 10 public virtual void UnsecuredMethod() {} 11 12 [EnvironmentPermission(SecurityAction.InheritanceDemand, Read = "PATH")] 13 public virtual void SecuredMethod() { } 14 } 15 }
The following example shows a type that violates the rule.