Posts

Showing posts with the label reflection

Isolator with References Scanning

Introduction I recently posted about my projects  Isolator and ReferencesScanner , which allow us, respectively, to run .NET code in isolation and to list all of an assembly's references. Now, I'm going to present a change to  Isolator  that allows checking for a plugin's references with white and black lists. Any references on the white list will be allowed, and any on the black list will be denied. Using Isolator with References Scanning There is a new class, ScannedIsolationHost , which features four new properties: public HashSet<Type> SafeTypes { get; } public HashSet<Assembly> SafeAssemblies { get; } public HashSet<Type> UnsafeTypes { get; } public HashSet<Assembly> UnsafeAssemblies { get; } So, we have new properties: SafeTypes : list of Type references that are safe to use SafeAssemblies : list of Assembly references that are safe to use UnsafeTypes : list of  Type  references that are unsafe to use UnsafeAssemblies :...

Scanning .NET Assemblies for References

Introduction As part of my work on running code in isolation , or sandbox, I set out to investigate how can we restrict what the hosted code runs, or, at least, find out what it is trying to do. I was interested in finding out what references does an assembly have, not just assembly references, but what types and methods it is actually accessing, from other assemblies. I ran into an old acquaintance, Mono.Cecil , which can helps us do just that, as I'll explain. Introducing Mono.Cecil From it's page on the Mono Project site: " Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. With Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly." Cecil  is part of Mono Project , a most interesting initiative, which you should be aware of, if not already. It started in the old days of .NET Framework, when it wasn...