/// <summary> /// Used for retrieving applied source security attributes, i.e. attributes derived from well-known SecurityAttribute. /// </summary> public IEnumerable <Cci.SecurityAttribute> GetSecurityAttributes <T>(ImmutableArray <T> customAttributes) where T : Cci.ICustomAttribute { Debug.Assert(!customAttributes.IsDefault); Debug.Assert(_lazyPathsForPermissionSetFixup == null || _lazySecurityActions != null && _lazyPathsForPermissionSetFixup.Length == _lazySecurityActions.Length); if (_lazySecurityActions != null) { Debug.Assert(_lazySecurityActions != null); Debug.Assert(_lazySecurityActions.Length == customAttributes.Length); for (int i = 0; i < customAttributes.Length; i++) { if (_lazySecurityActions[i] != 0) { DeclarativeSecurityAction action = (DeclarativeSecurityAction)_lazySecurityActions[i]; Cci.ICustomAttribute attribute = customAttributes[i]; if (_lazyPathsForPermissionSetFixup?[i] != null) { attribute = new PermissionSetAttributeWithFileReference(attribute, _lazyPathsForPermissionSetFixup[i]); } yield return(new Cci.SecurityAttribute(action, attribute)); } } } }
internal void DecodeSecurityAttribute <T>(Symbol targetSymbol, CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments <AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) where T : WellKnownAttributeData, ISecurityAttributeTarget, new() { Debug.Assert(!this.HasErrors); Debug.Assert(arguments.Diagnostics is BindingDiagnosticBag); bool hasErrors; DeclarativeSecurityAction action = DecodeSecurityAttributeAction(targetSymbol, compilation, arguments.AttributeSyntaxOpt, out hasErrors, (BindingDiagnosticBag)arguments.Diagnostics); if (!hasErrors) { T data = arguments.GetOrCreateData <T>(); SecurityWellKnownAttributeData securityData = data.GetOrCreateData(); securityData.SetSecurityAttribute(arguments.Index, action, arguments.AttributesCount); if (this.IsTargetAttribute(targetSymbol, AttributeDescription.PermissionSetAttribute)) { string?resolvedPathForFixup = DecodePermissionSetAttribute(compilation, arguments.AttributeSyntaxOpt, (BindingDiagnosticBag)arguments.Diagnostics); if (resolvedPathForFixup != null) { securityData.SetPathForPermissionSetAttributeFixup(arguments.Index, resolvedPathForFixup, arguments.AttributesCount); } } } }
public void SetSecurityAttribute(int attributeIndex, DeclarativeSecurityAction action, int totalSourceAttributes) { Debug.Assert(attributeIndex >= 0 && attributeIndex < totalSourceAttributes); Debug.Assert(action != 0); if (_lazySecurityActions == null) { Interlocked.CompareExchange(ref _lazySecurityActions, new byte[totalSourceAttributes], null); } Debug.Assert(_lazySecurityActions.Length == totalSourceAttributes); _lazySecurityActions[attributeIndex] = (byte)action; }
public void AddDeclarativeSecurityAttribute( EntityHandle parent, DeclarativeSecurityAction action, BlobHandle permissionSet) { uint parentCodedIndex = (uint)CodedIndex.ToHasDeclSecurity(parent); // the table is required to be sorted by Parent: _declSecurityTableNeedsSorting |= parentCodedIndex < _declSecurityTableLastParent; _declSecurityTableLastParent = parentCodedIndex; _declSecurityTable.Add(new DeclSecurityRow { Parent = parentCodedIndex, Action = (ushort)action, PermissionSet = permissionSet }); }
public SecurityAttribute(DeclarativeSecurityAction action, ICustomAttribute attribute) { Action = action; Attribute = attribute; }
public void AddDeclarativeSecurityAttribute( uint parent, DeclarativeSecurityAction action, BlobIdx permissionSet) { // the table is required to be sorted by Parent: _declSecurityTableNeedsSorting |= parent < _declSecurityTableLastParent; _declSecurityTableLastParent = parent; _declSecurityTable.Add(new DeclSecurityRow { Parent = parent, Action = (ushort)action, PermissionSet = permissionSet }); }