The Labs \ Source Viewer \ SSCLI \ System.Security \ SecurityTreatAsSafeAttribute

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. using System.Runtime.InteropServices;
  16. namespace System.Security
  17. {
  18.     // DynamicSecurityMethodAttribute:
  19.     // Indicates that calling the target method requires space for a security
  20.     // object to be allocated on the callers stack. This attribute is only ever
  21.     // set on certain security methods defined within mscorlib.
  22.     [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
  23.     internal sealed class DynamicSecurityMethodAttribute : System.Attribute
  24.     {
  25.     }
  26.    
  27.     // SuppressUnmanagedCodeSecurityAttribute:
  28.     // Indicates that the target P/Invoke method(s) should skip the per-call
  29.     // security checked for unmanaged code permission.
  30.     [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = true, Inherited = false)]
  31.     [System.Runtime.InteropServices.ComVisible(true)]
  32.     public sealed class SuppressUnmanagedCodeSecurityAttribute : System.Attribute
  33.     {
  34.     }
  35.    
  36.     // UnverifiableCodeAttribute:
  37.     // Indicates that the target module contains unverifiable code.
  38.     [AttributeUsage(AttributeTargets.Module, AllowMultiple = true, Inherited = false)]
  39.     [System.Runtime.InteropServices.ComVisible(true)]
  40.     public sealed class UnverifiableCodeAttribute : System.Attribute
  41.     {
  42.     }
  43.    
  44.     // AllowPartiallyTrustedCallersAttribute:
  45.     // Indicates that the Assembly is secure and can be used by untrusted
  46.     // and semitrusted clients
  47.     // For v.1, this is valid only on Assemblies, but could be expanded to
  48.     // include Module, Method, class
  49.     [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
  50.     [System.Runtime.InteropServices.ComVisible(true)]
  51.     public sealed class AllowPartiallyTrustedCallersAttribute : System.Attribute
  52.     {
  53.         public AllowPartiallyTrustedCallersAttribute()
  54.         {
  55.         }
  56.     }
  57.    
  58.     public enum SecurityCriticalScope
  59.     {
  60.         Explicit = 0,
  61.         Everything = 1
  62.     }
  63.    
  64.     // SecurityCriticalAttribute
  65.     // Indicates that the decorated code or assembly performs security critical operations (e.g. Assert, "unsafe", LinkDemand, etc.)
  66.     // The attribute can be placed on most targets, except on arguments/return values.
  67.     // The attribute applies only to the specific target and not to everything underneath it (similar to 'public' qualifier)
  68.     // i.e. marking an assembly SecurityCritical doesn't imply all types within the assembly are critical,
  69.     // and similarly marking a type critical doesn't imply all of its members are critical
  70.     // For code to perform security critical actions, both the code (e.g. method, field, etc.) and the assembly must be decorated
  71.     // with the SecurityCriticalAttribute.
  72.    
  73.     [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
  74.     public sealed class SecurityCriticalAttribute : System.Attribute
  75.     {
  76.         internal SecurityCriticalScope _val;
  77.         public SecurityCriticalAttribute()
  78.         {
  79.         }
  80.         public SecurityCriticalAttribute(SecurityCriticalScope scope)
  81.         {
  82.             _val = scope;
  83.         }
  84.        
  85.         public SecurityCriticalScope Scope {
  86.             get { return _val; }
  87.         }
  88.     }
  89.    
  90.     // SecurityTreatAsSafeAttribute:
  91.     // Indicates that the code may contain violations to the security critical rules (e.g. transitions from
  92.     // critical to non-public transparent, transparent to non-public critical, etc.), has been audited for
  93.     // security concerns and is considered security clean.
  94.     // At assembly-scope, all rule checks will be suppressed within the assembly and for calls made against the assembly.
  95.     // At type-scope, all rule checks will be suppressed for members within the type and for calls made against the type.
  96.     // At member level (e.g. field and method) the code will be treated as public - i.e. no rule checks for the members.
  97.    
  98.     [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
  99.     public sealed class SecurityTreatAsSafeAttribute : System.Attribute
  100.     {
  101.         public SecurityTreatAsSafeAttribute()
  102.         {
  103.         }
  104.     }
  105.    
  106.     // SecurityTransparentAttribute:
  107.     // Indicates the assembly contains only transparent code.
  108.     // Security critical actions will be restricted or converted into less critical actions. For example,
  109.     // Assert will be restricted, SuppressUnmanagedCode, LinkDemand, unsafe, and unverifiable code will be converted
  110.     // into Full-Demands.
  111.    
  112.     [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
  113.     public sealed class SecurityTransparentAttribute : System.Attribute
  114.     {
  115.         public SecurityTransparentAttribute()
  116.         {
  117.         }
  118.     }
  119. }

Developer Fusion