This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move System.Security attributes to shared partition. (#10036)
* Split System\Security\Attributes.cs into properly named files. * Formatting cleanup "sealed public" => "public sealed" "System.Attribute" => "Attribute" Use autoprops when possible. Be explicit about nullary constructors (since 90% of them already were.) * Remove blank line.
- Loading branch information
1 parent
4e9f016
commit dd0dd22
Showing
15 changed files
with
269 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/mscorlib/shared/System/Security/AllowPartiallyTrustedCallersAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// AllowPartiallyTrustedCallersAttribute: | ||
// Indicates that the Assembly is secure and can be used by untrusted | ||
// and semitrusted clients | ||
// For v.1, this is valid only on Assemblies, but could be expanded to | ||
// include Module, Method, class | ||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] | ||
public sealed class AllowPartiallyTrustedCallersAttribute : Attribute | ||
{ | ||
public AllowPartiallyTrustedCallersAttribute() { } | ||
public PartialTrustVisibilityLevel PartialTrustVisibilityLevel { get; set; } | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
src/mscorlib/shared/System/Security/PartialTrustVisibilityLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
public enum PartialTrustVisibilityLevel | ||
{ | ||
VisibleToAllHosts = 0, | ||
NotVisibleByDefault = 1 | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
src/mscorlib/shared/System/Security/SecurityCriticalAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// SecurityCriticalAttribute | ||
// Indicates that the decorated code or assembly performs security critical operations (e.g. Assert, "unsafe", LinkDemand, etc.) | ||
// The attribute can be placed on most targets, except on arguments/return values. | ||
[AttributeUsage(AttributeTargets.Assembly | | ||
AttributeTargets.Class | | ||
AttributeTargets.Struct | | ||
AttributeTargets.Enum | | ||
AttributeTargets.Constructor | | ||
AttributeTargets.Method | | ||
AttributeTargets.Field | | ||
AttributeTargets.Interface | | ||
AttributeTargets.Delegate, | ||
AllowMultiple = false, | ||
Inherited = false)] | ||
public sealed class SecurityCriticalAttribute : Attribute | ||
{ | ||
#pragma warning disable 618 // We still use SecurityCriticalScope for v2 compat | ||
public SecurityCriticalAttribute() { } | ||
|
||
public SecurityCriticalAttribute(SecurityCriticalScope scope) | ||
{ | ||
Scope = scope; | ||
} | ||
|
||
[Obsolete("SecurityCriticalScope is only used for .NET 2.0 transparency compatibility.")] | ||
public SecurityCriticalScope Scope { get; } | ||
#pragma warning restore 618 | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
src/mscorlib/shared/System/Security/SecurityCriticalScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
[Obsolete("SecurityCriticalScope is only used for .NET 2.0 transparency compatibility.")] | ||
public enum SecurityCriticalScope | ||
{ | ||
Explicit = 0, | ||
Everything = 0x1 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
public enum SecurityRuleSet : byte | ||
{ | ||
None = 0, | ||
Level1 = 1, // v2.0 transparency model | ||
Level2 = 2, // v4.0 transparency model | ||
} | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
src/mscorlib/shared/System/Security/SecurityRulesAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// SecurityRulesAttribute | ||
// | ||
// Indicates which set of security rules an assembly was authored against, and therefore which set of | ||
// rules the runtime should enforce on the assembly. For instance, an assembly marked with | ||
// [SecurityRules(SecurityRuleSet.Level1)] will follow the v2.0 transparency rules, where transparent code | ||
// can call a LinkDemand by converting it to a full demand, public critical methods are implicitly | ||
// treat as safe, and the remainder of the v2.0 rules apply. | ||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] | ||
public sealed class SecurityRulesAttribute : Attribute | ||
{ | ||
public SecurityRulesAttribute(SecurityRuleSet ruleSet) | ||
{ | ||
RuleSet = ruleSet; | ||
} | ||
|
||
// Should fully trusted transparent code skip IL verification | ||
public bool SkipVerificationInFullTrust { get; set; } | ||
|
||
public SecurityRuleSet RuleSet { get; } | ||
} | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
src/mscorlib/shared/System/Security/SecuritySafeCriticalAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// SecuritySafeCriticalAttribute: | ||
// Indicates that the code may contain violations to the security critical rules (e.g. transitions from | ||
// critical to non-public transparent, transparent to non-public critical, etc.), has been audited for | ||
// security concerns and is considered security clean. Also indicates that the code is considered SecurityCritical. | ||
// The effect of this attribute is as if the code was marked [SecurityCritical][SecurityTreatAsSafe]. | ||
// At assembly-scope, all rule checks will be suppressed within the assembly and for calls made against the assembly. | ||
// At type-scope, all rule checks will be suppressed for members within the type and for calls made against the type. | ||
// At member level (e.g. field and method) the code will be treated as public - i.e. no rule checks for the members. | ||
|
||
[AttributeUsage(AttributeTargets.Class | | ||
AttributeTargets.Struct | | ||
AttributeTargets.Enum | | ||
AttributeTargets.Constructor | | ||
AttributeTargets.Method | | ||
AttributeTargets.Field | | ||
AttributeTargets.Interface | | ||
AttributeTargets.Delegate, | ||
AllowMultiple = false, | ||
Inherited = false)] | ||
public sealed class SecuritySafeCriticalAttribute : Attribute | ||
{ | ||
public SecuritySafeCriticalAttribute() { } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/mscorlib/shared/System/Security/SecurityTransparentAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// SecurityTransparentAttribute: | ||
// Indicates the assembly contains only transparent code. | ||
// Security critical actions will be restricted or converted into less critical actions. For example, | ||
// Assert will be restricted, SuppressUnmanagedCode, LinkDemand, unsafe, and unverifiable code will be converted | ||
// into Full-Demands. | ||
|
||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] | ||
public sealed class SecurityTransparentAttribute : Attribute | ||
{ | ||
public SecurityTransparentAttribute() { } | ||
} | ||
} | ||
|
32 changes: 32 additions & 0 deletions
32
src/mscorlib/shared/System/Security/SecurityTreatAsSafeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// SecurityTreatAsSafeAttribute: | ||
// Indicates that the code may contain violations to the security critical rules (e.g. transitions from | ||
// critical to non-public transparent, transparent to non-public critical, etc.), has been audited for | ||
// security concerns and is considered security clean. | ||
// At assembly-scope, all rule checks will be suppressed within the assembly and for calls made against the assembly. | ||
// At type-scope, all rule checks will be suppressed for members within the type and for calls made against the type. | ||
// At member level (e.g. field and method) the code will be treated as public - i.e. no rule checks for the members. | ||
|
||
[AttributeUsage(AttributeTargets.Assembly | | ||
AttributeTargets.Class | | ||
AttributeTargets.Struct | | ||
AttributeTargets.Enum | | ||
AttributeTargets.Constructor | | ||
AttributeTargets.Method | | ||
AttributeTargets.Field | | ||
AttributeTargets.Interface | | ||
AttributeTargets.Delegate, | ||
AllowMultiple = false, | ||
Inherited = false)] | ||
[Obsolete("SecurityTreatAsSafe is only used for .NET 2.0 transparency compatibility. Please use the SecuritySafeCriticalAttribute instead.")] | ||
public sealed class SecurityTreatAsSafeAttribute : Attribute | ||
{ | ||
public SecurityTreatAsSafeAttribute() { } | ||
} | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
src/mscorlib/shared/System/Security/SuppressUnmanagedCodeSecurityAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// SuppressUnmanagedCodeSecurityAttribute: | ||
// Indicates that the target P/Invoke method(s) should skip the per-call | ||
// security checked for unmanaged code permission. | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = true, Inherited = false)] | ||
public sealed class SuppressUnmanagedCodeSecurityAttribute : Attribute | ||
{ | ||
public SuppressUnmanagedCodeSecurityAttribute() { } | ||
} | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
src/mscorlib/shared/System/Security/UnverifiableCodeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.Security | ||
{ | ||
// UnverifiableCodeAttribute: | ||
// Indicates that the target module contains unverifiable code. | ||
[AttributeUsage(AttributeTargets.Module, AllowMultiple = true, Inherited = false)] | ||
public sealed class UnverifiableCodeAttribute : Attribute | ||
{ | ||
public UnverifiableCodeAttribute() { } | ||
} | ||
} | ||
|
Oops, something went wrong.