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: list of Assembly references that are unsafe to use

ScannedIsolationHost must be instantiated with an existing IIsolationHost, and, possibly, with some of these collection properties filled.

In a nutshell:

  1. If either the SafeTypes or SafeAssemblies are specified, then every referenced method's type/assembly must be declared there
  2. No referenced method's type/assembly can be present in the UnsafeTypes/UnsafeAssemblies collections, if any is specified

The Isolator has been updated, both GitHub and NuGet, so you can use this already.

Conclusion

As always, happy to hear your thoughts on this, and I hope you find this useful!

Comments

Popular posts from this blog

C# Magical Syntax

OpenTelemetry with ASP.NET Core

ASP.NET Core Middleware