New test.
[mono.git] / mono / tests / cas / linkdemand / README
1 * LinkDemand
2
3 cas1.cs         LinkDemand on Main (entrypoint) is ignored
4 cas2.cs         LinkDemand restricted by RequestRefuse -> Unhandled
5 cas3.cs         Partial execution before (handled) exception
6 cas6.cs         LinkDemand on constructor (newobj)
7 cas7.cs         Instance method used via delegate (ldftn)
8 cas8.cs         Instance virtual method used via delegate (ldvirtftn)
9 cas9.cs         Static method used via delegate (ldftn)
10 cas10.cs        Original source code JMP sample (can't be used directly)
11 cas10.il        Modified source to use JMP - not assembled ATM -
12                 see source file (cas10.cs) for details
13
14 refcas1.cs      Reflection on a method protected by LinkDemand (granted)
15 refcas2.cs      Reflection on a method protected by LinkDemand (failure).
16                 GetMethod returns null because of assembly RequestRefuse.
17 refcas3.cs      Reflection on a method protected by LinkDemand (failure).
18                 GetMethod returns non-null because the LinkDemand doesn't go 
19                 up enough the stack.
20 refcas4.cs      Based on refcas3.cs. Getting the MethodInfo is allowed but
21                 invoking it later is restricted.
22 refcas5.cs      Based on refcas5.cs. Test that invokation requires a Demand
23                 and not a LinkDemand when reflection is used.
24
25 noncas1.cs      Non CAS (PrincipalPermission) on class (success)
26 noncas2.cs      Non CAS (PrincipalPermission) on class (failure)
27 noncas3.cs      Non CAS (PrincipalPermission) on method (success)
28 noncas4.cs      Non CAS (PrincipalPermission) on method (failure)
29
30 Those are the "common" case for LinkDemand (i.e. using user supplied 
31 declarative security attributes).
32
33
34 and now the special cases...
35
36
37 * InternalCall
38
39 icall1.cs       Define an (existing) private icall and try to execute it.
40 icall2.cs       Use reflection to execute an private icall.
41 icall3.cs       Define an (existing) public icall and try to execute it.
42 icall4.cs       Like icall3.cs but use reflection to execute the public icall.
43 icall5.cs       Like icall3.cs but RequestRefuse UnmanagedCode permission.
44 icall6.cs       Like icall4.cs but RequestRefuse UnmanagedCode permission.
45
46 - Private icalls cannot be called by re-defining them (exact rule unknown,
47   it may be ECMA key related but I'm not 100% sure anymore). Trying to do so
48   throws a (catch-able) SecurityException.
49 - UnmanagedCode permission has _no_ effect on executing icalls.
50 - Reflection can be used to call internal calls (even when private).
51
52
53 * P/Invoke
54
55 pinvoke1.cs     Call native code in a class with [SUCS] attribute
56 pinvoke2.cs     Call native code in a method with [SUCS] attribute
57 pinvoke3.cs     Call native code RequestRefuse UnmanagedCode permission 
58                 which results in an unhandled SecurityException
59 pinvoke4.cs     Call native code RequestRefuse UnmanagedCode permission
60                 which results in an SecurityException
61
62 A little know fact is that P/Invoke does a LinkDemand (JIT time) and not
63 only a Demand (runtime). The JIT time check isn't subject to be cancelled
64 by the [SuppressUnmanagedCodeSecurity] attribute.
65
66 - With Mono runtime the native function getuid is called in libc
67 - With MS runtime the native function GetTickCount is called in kernel32.dll
68
69
70 * [AllowPartiallyTustedCallers] a.k.a. APTC
71
72 aptc1.cs        Calling a strongnamed with APTC (corlib) method [1].
73 aptc2.cs        Calling a strongnamed without APTC (aptclib) method.
74 aptclib.cs      The strongnamed, but without APTC, test library.
75
76 The files aptc1.cs and aptc2.cs are compiled twice. 
77
78 The first time the files are compiled without restrictions (e.g. they have
79 FullTrust by default). The second time SkipVerification is refused at the
80 asssembly level (i.e. resulting in less than FullTrust). This means that the
81 security manager (if active) will allow the call to succeed _only if_
82
83         (a) the calling assembly has FullTrust;
84         (b) the called assembly has a [AllowPartiallyTustedCallers] attribute
85
86 [1] For example an unsigned assembly can calls System.Console.WriteLine only
87 because mscorlib.dll contains the [AllowPartiallyTustedCallers].