Beispiel #1
0
 public static bool IsSafeBinaryFormatterStreamWithAllowList(Stream serializationStream, IEnumerable <Type> allowList, SafeSerialization.TypeEncounteredDelegate typeEncounteredCallback = null)
 {
     return(SafeSerialization.IsSafeBinaryFormatterStreamCommon(new SafeSerialization.ValidatingBinder(new SafeSerialization.AllowList(allowList), typeEncounteredCallback), serializationStream));
 }
Beispiel #2
0
 public ValidatingBinder(SafeSerialization.AllowList allowList, SafeSerialization.TypeEncounteredDelegate typeEncounteredCallback)
 {
     this.allowedTypes      = ((allowList != null) ? new HashSet <Type>(allowList.List) : new HashSet <Type>());
     this.typeFoundCallback = typeEncounteredCallback;
 }
Beispiel #3
0
        public static object SafeBinaryFormatterDeserializeWithAllowList(Stream stream, IEnumerable <Type> allowList, SafeSerialization.TypeEncounteredDelegate typeEncounteredCallback = null)
        {
            SafeSerialization.ValidatingBinder binder = new SafeSerialization.ValidatingBinder(new SafeSerialization.AllowList(allowList), typeEncounteredCallback);
            BinaryFormatter binaryFormatter           = ExchangeBinaryFormatterFactory.CreateBinaryFormatter(null);

            binaryFormatter.Binder = binder;
            return(binaryFormatter.Deserialize(stream));
        }