Ejemplo n.º 1
0
 public override void Visit(ISecurityAttribute securityAttribute)
 {
     if (Process(securityAttribute))
     {
         visitor.Visit(securityAttribute);
     }
     base.Visit(securityAttribute);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 //^ 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();
 }
Ejemplo n.º 5
0
 public void Visit(ISecurityAttribute securityAttribute)
 {
     throw new NotImplementedException();
 }
 public override void Visit(ISecurityAttribute securityAttribute)
 {
     if(Process(securityAttribute)){visitor.Visit(securityAttribute);}
     base.Visit(securityAttribute);
 }
Ejemplo n.º 7
0
 public virtual void onMetadataElement(ISecurityAttribute securityAttribute) { }
Ejemplo n.º 8
0
 /// <summary>
 /// Traverses the security attribute.
 /// </summary>
 public override void TraverseChildren(ISecurityAttribute securityAttribute)
 {
     this.validator.currentSecurityAttribute = securityAttribute;
     base.TraverseChildren(securityAttribute);
     this.validator.currentSecurityAttribute = null;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Performs some computation with the given security attribute.
 /// </summary>
 public virtual void Visit(ISecurityAttribute securityAttribute)
 {
 }
 /// <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;
 }
Ejemplo n.º 12
0
 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;
 }
Ejemplo n.º 13
0
 private static System.Security.Permissions.SecurityAction GetSecurityAction(ISecurityAttribute securityAttribute) {
   return (System.Security.Permissions.SecurityAction)securityAttribute.Action;
 }
Ejemplo n.º 14
0
 public override void Visit(ISecurityAttribute securityAttribute)
 {
     allElements.Add(new InvokInfo(Traverser, "ISecurityAttribute", securityAttribute));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Traverses the children of the security attribute.
 /// </summary>
 public virtual void TraverseChildren(ISecurityAttribute securityAttribute)
 {
     Contract.Requires(securityAttribute != null);
       this.Traverse(securityAttribute.Attributes);
 }
Ejemplo n.º 16
0
 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();
 }
Ejemplo n.º 18
0
 /// <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;
     }
 }
Ejemplo n.º 19
0
 public virtual void onMetadataElement(ISecurityAttribute securityAttribute)
 {
 }
 public override void TraverseChildren(ISecurityAttribute securityAttribute) {
   base.TraverseChildren(securityAttribute);
 }
Ejemplo n.º 21
0
        public override void TraverseChildren(ISecurityAttribute securityAttribute)
{ MethodEnter(securityAttribute);
            base.TraverseChildren(securityAttribute);
     MethodExit();   }
Ejemplo n.º 22
0
 public override void TraverseChildren(ISecurityAttribute securityAttribute)
 {
     MethodEnter(securityAttribute);
     base.TraverseChildren(securityAttribute);
     MethodExit();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Traverses the children of the security attribute.
 /// </summary>
 public virtual void TraverseChildren(ISecurityAttribute securityAttribute)
 {
     this.Traverse(securityAttribute.Attributes);
 }