dotnet / infer

Infer.NET is a framework for running Bayesian inference in graphical models
https://dotnet.github.io/infer/
MIT License
1.56k stars 228 forks source link

Remove InferDataContractResolver #451

Closed jonathantims closed 1 year ago

jonathantims commented 1 year ago

Security compliance requires us to remove the InferDataContractResolver because it resolves any type encoded in the payload. Instead replacing with explicit known types. Apart from IDistribution this can be put directly on the relevant base types. But IDistribution is an interface, so instead I have demonstrated how to manually add add the required known types to the serializer on each use. (See SerializableTest.cs line 287.)

Alternatives:

  1. Do not use base-class KnownTypes and instead always add KnownTypes to SerializerSettings (like for IDistribution).
  2. Change IDistribution to an abstract base class so that it can take KnownTypes (this might not be possible without a lot of knock-on changes).