public virtual void Method() { //Console.WriteLine ("sc class"); CClass cc = new CClass(); cc.Method(); }
public static int Main() { SCMethod(); try { CMethod(); error("static critical method called"); } catch (MethodAccessException) { } SCClass sc = new SCClass(); sc.Method(); try { CClass c = new CClass(); // Illegal error("critical object instantiated"); c.Method(); // Illegal error("critical method called"); } catch (MethodAccessException) { } try { doSCDev(); error("security-critical-derived class error"); } catch (TypeLoadException) { } try { doCMethodDev(); } catch (TypeLoadException) { } try { getpid(); error("pinvoke called"); } catch (MethodAccessException) { } try { MethodDelegate md = new MethodDelegate(CClass.StaticMethod); md(); error("critical method called via delegate"); } catch (MethodAccessException) { } try { CriticalClass.NestedClassInsideCritical.Method(); } catch (MethodAccessException) { } try { doSCInterfaceDev(); } catch (TypeLoadException) { } /* * try { * unsafeMethod (); * } catch (VerificationException) { * } */ try { Type type = Type.GetType("Test"); MethodInfo method = type.GetMethod("TransparentReflectionCMethod"); method.Invoke(null, null); } catch (MethodAccessException) { error("transparent method not called via reflection"); } try { Type type = Type.GetType("Test"); MethodInfo method = type.GetMethod("ReflectionCMethod"); method.Invoke(null, null); } catch (MethodAccessException) { } try { Type type = Type.GetType("Test"); MethodInfo method = type.GetMethod("TransparentReflectionCMethod"); InvokeDelegate id = new InvokeDelegate(method.Invoke); id(null, null); } catch (MethodAccessException) { error("transparent method not called via reflection delegate"); } try { Type type = Type.GetType("Test"); MethodInfo method = type.GetMethod("ReflectionCMethod"); InvokeDelegate id = new InvokeDelegate(method.Invoke); id(null, null); } catch (MethodAccessException) { } // wrapper 7 try { CallStringTest(); } catch (MethodAccessException) { error("string test failed"); } try { doBadTransparentOverrideClass(); error("BadTransparentOverrideClass error"); } catch (TypeLoadException) { } try { doBadSafeCriticalOverrideClass(); error("BadSafeCriticalOverrideClass error"); } catch (TypeLoadException) { } try { doBadCriticalOverrideClass(); error("BadCriticalOverrideClass error"); } catch (TypeLoadException) { } new TransparentClassWithSafeCriticalDefaultConstructor(); try { new TransparentInheritFromSafeCriticalDefaultConstructor(); } catch (TypeLoadException) { } new SafeInheritFromSafeCriticalDefaultConstructor(); // arrays creation tests ArraysCreatedByTransparentCaller(); ArraysCreatedBySafeCriticalCaller(); // the above also calls ArraysCreatedBySafeCriticalCaller since (Transparent) Main cannot call it directly if (haveError) { return(1); } // Console.WriteLine ("ok"); return(0); }
public static int Main() { SCMethod (); try { CMethod (); error ("static critical method called"); } catch (MethodAccessException) { } SCClass sc = new SCClass (); sc.Method (); try { CClass c = new CClass (); // Illegal error ("critical object instantiated"); c.Method (); // Illegal error ("critical method called"); } catch (MethodAccessException) { } try { doSCDev (); error ("security-critical-derived class error"); } catch (TypeLoadException) { } try { doCMethodDev (); } catch (TypeLoadException) { } try { getpid (); error ("pinvoke called"); } catch (MethodAccessException) { } try { MethodDelegate md = new MethodDelegate (CClass.StaticMethod); md (); error ("critical method called via delegate"); } catch (MethodAccessException) { } try { CriticalClass.NestedClassInsideCritical.Method (); } catch (MethodAccessException) { } try { doSCInterfaceDev (); } catch (TypeLoadException) { } /* try { unsafeMethod (); } catch (VerificationException) { } */ try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("TransparentReflectionCMethod"); method.Invoke(null, null); } catch (MethodAccessException) { error ("transparent method not called via reflection"); } try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("ReflectionCMethod"); method.Invoke(null, null); } catch (MethodAccessException) { } try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("TransparentReflectionCMethod"); InvokeDelegate id = new InvokeDelegate (method.Invoke); id (null, null); } catch (MethodAccessException) { error ("transparent method not called via reflection delegate"); } try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("ReflectionCMethod"); InvokeDelegate id = new InvokeDelegate (method.Invoke); id (null, null); } catch (MethodAccessException) { } //Console.WriteLine ("ok"); if (haveError) return 1; return 0; }
public virtual void Method() { //Console.WriteLine ("sc class"); CClass cc = new CClass (); cc.Method (); }
public virtual void Method() { CClass cc = new CClass (); cc.Method (); }
public static int Main () { SCMethod (); try { CMethod (); error ("static critical method called"); } catch (MethodAccessException) { } SCClass sc = new SCClass (); sc.Method (); try { CClass c = new CClass (); // Illegal error ("critical object instantiated"); c.Method (); // Illegal error ("critical method called"); } catch (MethodAccessException) { } try { doSCDev (); error ("security-critical-derived class error"); } catch (TypeLoadException) { } try { doCMethodDev (); } catch (TypeLoadException) { } try { getpid (); error ("pinvoke called"); } catch (MethodAccessException) { } try { MethodDelegate md = new MethodDelegate (CClass.StaticMethod); md (); error ("critical method called via delegate"); } catch (MethodAccessException) { } try { CriticalClass.NestedClassInsideCritical.Method (); } catch (MethodAccessException) { } try { doSCInterfaceDev (); } catch (TypeLoadException) { } /* try { unsafeMethod (); } catch (VerificationException) { } */ try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("TransparentReflectionCMethod"); method.Invoke(null, null); } catch (MethodAccessException) { error ("transparent method not called via reflection"); } try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("ReflectionCMethod"); method.Invoke(null, null); } catch (MethodAccessException) { } try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("TransparentReflectionCMethod"); InvokeDelegate id = new InvokeDelegate (method.Invoke); id (null, null); } catch (MethodAccessException) { error ("transparent method not called via reflection delegate"); } try { Type type = Type.GetType ("Test"); MethodInfo method = type.GetMethod ("ReflectionCMethod"); InvokeDelegate id = new InvokeDelegate (method.Invoke); id (null, null); } catch (MethodAccessException) { } // wrapper 7 try { CallStringTest (); } catch (MethodAccessException) { error ("string test failed"); } try { doBadTransparentOverrideClass (); error ("BadTransparentOverrideClass error"); } catch (TypeLoadException) { } try { doBadSafeCriticalOverrideClass (); error ("BadSafeCriticalOverrideClass error"); } catch (TypeLoadException) { } try { doBadCriticalOverrideClass (); error ("BadCriticalOverrideClass error"); } catch (TypeLoadException) { } new TransparentClassWithSafeCriticalDefaultConstructor (); try { new TransparentInheritFromSafeCriticalDefaultConstructor (); } catch (TypeLoadException) { } new SafeInheritFromSafeCriticalDefaultConstructor (); // arrays creation tests ArraysCreatedByTransparentCaller (); ArraysCreatedBySafeCriticalCaller (); // the above also calls ArraysCreatedBySafeCriticalCaller since (Transparent) Main cannot call it directly if (haveError) return 1; // Console.WriteLine ("ok"); return 0; }