public override void Visit(ISecurityAttribute securityAttribute) { if (Process(securityAttribute)) { visitor.Visit(securityAttribute); } base.Visit(securityAttribute); }
public override List <ISecurityAttribute> Rewrite(List <ISecurityAttribute> securityAttributes) { if (!_removeDesktopSecurity) { return(securityAttributes); } List <ISecurityAttribute> newList = new List <ISecurityAttribute>(); if (securityAttributes == null) { return(newList); } foreach (ISecurityAttribute sa in securityAttributes) { bool removeSA = false; if (sa.Action == SecurityAction.LinkDemand || sa.Action == SecurityAction.InheritanceDemand) { removeSA = true; foreach (ICustomAttribute attribute in sa.Attributes) { if (Util.GetTypeName(attribute.Type) == "System.Security.Permissions.HostProtectionAttribute") { removeSA = false; } } } if (!removeSA) { ISecurityAttribute newSA = sa; newList.Add(Rewrite(newSA)); } } return(newList); }
/// <summary> /// Traverses the security attribute. /// </summary> public void Traverse(ISecurityAttribute securityAttribute) { Contract.Requires(securityAttribute != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(securityAttribute); if (this.stopTraversal) return; this.TraverseChildren(securityAttribute); if (this.stopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(securityAttribute); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Performs some computation with the given security attribute. /// </summary> /// <param name="securityAttribute"></param> public virtual void Visit(ISecurityAttribute securityAttribute) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(securityAttribute); this.Visit(securityAttribute.Attributes); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
public void Visit(ISecurityAttribute securityAttribute) { throw new NotImplementedException(); }
public override void Visit(ISecurityAttribute securityAttribute) { if(Process(securityAttribute)){visitor.Visit(securityAttribute);} base.Visit(securityAttribute); }
public virtual void onMetadataElement(ISecurityAttribute securityAttribute) { }
/// <summary> /// Traverses the security attribute. /// </summary> public override void TraverseChildren(ISecurityAttribute securityAttribute) { this.validator.currentSecurityAttribute = securityAttribute; base.TraverseChildren(securityAttribute); this.validator.currentSecurityAttribute = null; }
/// <summary> /// Performs some computation with the given security attribute. /// </summary> public virtual void Visit(ISecurityAttribute securityAttribute) { }
/// <summary> /// Rewrites the given security attribute. /// </summary> public virtual ISecurityAttribute Rewrite(ISecurityAttribute securityAttribute) { return securityAttribute; }
private System.Security.PermissionSet GetPermissionSet(ISecurityAttribute securityAttribute) { var result = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.None); foreach (var attribute in securityAttribute.Attributes) { var permission = this.GetPermission(securityAttribute.Action, attribute); if (permission == null) continue; //not a trusted permission result.AddPermission(permission); } return result; }
private static System.Security.Permissions.SecurityAction GetSecurityAction(ISecurityAttribute securityAttribute) { return (System.Security.Permissions.SecurityAction)securityAttribute.Action; }
public override void Visit(ISecurityAttribute securityAttribute) { allElements.Add(new InvokInfo(Traverser, "ISecurityAttribute", securityAttribute)); }
/// <summary> /// Traverses the children of the security attribute. /// </summary> public virtual void TraverseChildren(ISecurityAttribute securityAttribute) { Contract.Requires(securityAttribute != null); this.Traverse(securityAttribute.Attributes); }
public void Visit(ISecurityAttribute securityAttribute) { Contract.Assume(false); }
public void SecurityAttribute(ISecurityAttribute securityAttribute) { this.ILDasmPaper.Directive(".permissionset"); switch (securityAttribute.Action) { case SecurityAction.Assert: this.ILDasmPaper.Keyword("assert"); break; case SecurityAction.Demand: this.ILDasmPaper.Keyword("demand"); break; case SecurityAction.Deny: this.ILDasmPaper.Keyword("deny"); break; case SecurityAction.InheritanceDemand: this.ILDasmPaper.Keyword("inheritcheck"); break; case SecurityAction.LinkDemand: this.ILDasmPaper.Keyword("linkcheck"); break; case SecurityAction.PermitOnly: this.ILDasmPaper.Keyword("permitonly"); break; case SecurityAction.RequestMinimum: this.ILDasmPaper.Keyword("reqmin"); break; case SecurityAction.RequestOptional: this.ILDasmPaper.Keyword("reqopt"); break; case SecurityAction.RequestRefuse: this.ILDasmPaper.Keyword("reqrefuse"); break; } this.ILDasmPaper.NewLine(); this.ILDasmPaper.OpenBlock(); foreach (ICustomAttribute ca in securityAttribute.Attributes) { this.CustomAttribute(ca); } this.ILDasmPaper.CloseBlock(); }
/// <summary> /// Performs some computation with the given security attribute. /// </summary> public void Visit(ISecurityAttribute securityAttribute) { var currentType = this.validator.currentDefinition as ITypeDefinition; if (currentType != null && currentType.IsInterface) this.ReportError(MetadataError.SecurityAttributeOnInterface, securityAttribute, currentType); switch (securityAttribute.Action) { case SecurityAction.Assert: case SecurityAction.Demand: case SecurityAction.Deny: case SecurityAction.InheritanceDemand: case SecurityAction.LinkDemand: case SecurityAction.PermitOnly: if (!(this.validator.currentDefinition is IMethodDefinition || this.validator.currentDefinition is ITypeDefinition)) this.ReportError(MetadataError.SecurityActionMismatch, securityAttribute, this.validator.currentDefinition); //TODO: The specified attribute shall derive from System.Security.Permissions.CodeAccess-SecurityAttribute break; case SecurityAction.NonCasDemand: case SecurityAction.NonCasLinkDemand: if (!(this.validator.currentDefinition is IMethodDefinition || this.validator.currentDefinition is ITypeDefinition)) this.ReportError(MetadataError.SecurityActionMismatch, securityAttribute, this.validator.currentDefinition); //The attribute shall derive from System.Security.Permissions.SecurityAttribute, but shall not derive from System.Security.Permissions.CodeAccessSecurityAttribute break; case SecurityAction.ActionNil: case SecurityAction.NonCasInheritance: case SecurityAction.PrejitDenied: case SecurityAction.Request: break; case SecurityAction.PrejitGrant: case SecurityAction.RequestMinimum: case SecurityAction.RequestOptional: case SecurityAction.RequestRefuse: if (!(this.validator.currentDefinition is IAssembly)) this.ReportError(MetadataError.SecurityActionMismatch, securityAttribute, this.validator.currentDefinition); break; default: this.ReportError(MetadataError.InvalidSecurityAction, securityAttribute); break; } }
public override void TraverseChildren(ISecurityAttribute securityAttribute) { base.TraverseChildren(securityAttribute); }
public override void TraverseChildren(ISecurityAttribute securityAttribute) { MethodEnter(securityAttribute); base.TraverseChildren(securityAttribute); MethodExit(); }
/// <summary> /// Traverses the children of the security attribute. /// </summary> public virtual void TraverseChildren(ISecurityAttribute securityAttribute) { this.Traverse(securityAttribute.Attributes); }