Hello,
I've tried to embed the latest version of SSharp (from github) in my application to run scripts in a sandboxed AppDomain. It is essential for the entire SSharp assembly to be security transparent, so that scripts (they are untrusted) executed cannot randomly delete files on my computer. However, there are 3 places in SSharp access security critical code which requires elevated permissions:
1. The last method of MethodBinding.cs (
https://github.com/PetroProtsyk/SSharp/blob/master/SSharp.Net/Runtime/Promotion/MethodBinding.cs)
2. The last method of DelayedMethodBinding.cs (
https://github.com/PetroProtsyk/SSharp/blob/master/SSharp.Net/Runtime/Promotion/DelayedMethodBinding.cs)
3. The Initialize() and Dispose() methods of AssemblyManager (
https://github.com/PetroProtsyk/SSharp/blob/master/SSharp.Net/Runtime/AssemblyManager.cs)
In cases 1 and 2, the security critical method accessed is
return invokableMethod.Target.GetType().GetMethod(invokableMethod.MethodName).MethodHandle.GetFunctionPointer();
More specifically the GetFunctionPointer() part.
In case 3, the security critical methods accessed is
AppDomain.CurrentDomain.AssemblyLoad += CurrentDomainAssemblyLoad;
AppDomain.CurrentDomain.AssemblyLoad -= CurrentDomainAssemblyLoad;
I'm not worried about case 3 because I use BaseAssemblyManager instead to control which types are available to scripts. But I *do* worry about cases 1 and 2.
So here is my question:
What does the
public static implicit operator IntPtr(DelayedMethodBinding invokableMethod)
method do in cases 1 and 2 above? Because I've commented out the methods and everything still compiles and seems to work correctly. Is it safe to remove those methods
and still retain all (or most) features of SSharp?
Thanks,
Regards,
Lawrence.