Skip to content

Commit ead5056

Browse files
committed
Merge branch 'dev'
2 parents ea7ef0f + 2190f14 commit ead5056

25 files changed

Lines changed: 445 additions & 53 deletions

RELEASE_NOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### 0.12.2 March 31 2022 ####
2+
3+
* Fix [deserialization type cache was shared between multiple serializer instances](https://github.com/akkadotnet/Hyperion/pull/306)
4+
5+
### 0.12.1 March 23 2022 ####
6+
7+
* Fix disallow-unsafe-type Akka.NET settings and harden unsafe type detection [301](https://github.com/akkadotnet/Hyperion/pull/301)
8+
* Bump [Akka version from 1.4.34 to 1.4.35](https://github.com/akkadotnet/akka.net/releases/tag/1.4.35)
9+
110
### 0.12.0 January 12 2022 ####
211

312
* Allow explicit control over which types can be deserialized [#281](https://github.com/akkadotnet/Hyperion/pull/281)

build-system/pr-validation.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ jobs:
2121
vmImage: 'windows-2019'
2222
scriptFileName: build.cmd
2323
scriptArgs: all
24+
2425
- template: azure-pipeline.template.yaml
2526
parameters:
26-
name: 'linux_pr'
27-
displayName: 'Linux PR Validation'
27+
name: 'linux_pr_net_core'
28+
displayName: 'Linux PR Validation (netcoreapp3.1)'
2829
vmImage: 'ubuntu-16.04'
2930
scriptFileName: ./build.sh
30-
scriptArgs: all
31+
scriptArgs: runTestsNetCore
32+
33+
- template: azure-pipeline.template.yaml
34+
parameters:
35+
name: 'linux_pr_net_5'
36+
displayName: 'Linux PR Validation (net5.0)'
37+
vmImage: 'ubuntu-16.04'
38+
scriptFileName: ./build.sh
39+
scriptArgs: runTestsNet

build-system/windows-pr-validation.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@ jobs:
2020
vmImage: 'windows-2019'
2121
scriptFileName: build.cmd
2222
scriptArgs: all
23+
2324
- template: azure-pipeline.template.yaml
2425
parameters:
25-
name: 'linux_pr'
26-
displayName: 'Linux PR Validation'
26+
name: 'linux_pr_net_core'
27+
displayName: 'Linux PR Validation (netcoreapp3.1)'
2728
vmImage: 'ubuntu-18.04'
2829
scriptFileName: ./build.sh
29-
scriptArgs: all
30+
scriptArgs: runTestsNetCore
31+
32+
- template: azure-pipeline.template.yaml
33+
parameters:
34+
name: 'linux_pr_net_5'
35+
displayName: 'Linux PR Validation (net5.0)'
36+
vmImage: 'ubuntu-18.04'
37+
scriptFileName: ./build.sh
38+
scriptArgs: runTestsNet

build.fsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Target "Clean" (fun _ ->
7171

7272
CleanDirs !! "./**/bin"
7373
CleanDirs !! "./**/obj"
74+
75+
CreateDir "bin/nuget"
7476
)
7577

7678
Target "AssemblyInfo" (fun _ ->

src/Hyperion.API.Tests/Hyperion.API.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="ApprovalTests" Version="5.7.1" />
12+
<PackageReference Include="ApprovalTests" Version="5.7.2" />
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
1414
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
1515
<PackageReference Include="xunit" Version="$(XunitVersion)" />
1616
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVersion)">
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
<PrivateAssets>all</PrivateAssets>
1919
</PackageReference>
20-
<PackageReference Include="coverlet.collector" Version="3.1.0">
20+
<PackageReference Include="coverlet.collector" Version="3.1.2">
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
<PrivateAssets>all</PrivateAssets>
2323
</PackageReference>

src/Hyperion.Akka.Integration.Tests/Hyperion.Akka.Integration.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
<PrivateAssets>all</PrivateAssets>
2121
</PackageReference>
22-
<PackageReference Include="coverlet.collector" Version="3.1.0">
22+
<PackageReference Include="coverlet.collector" Version="3.1.2">
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
<PrivateAssets>all</PrivateAssets>
2525
</PackageReference>

src/Hyperion.Akka.Integration.Tests/IntegrationSpec.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Runtime.InteropServices;
6+
using System.Runtime.Serialization;
7+
using System.Security.Claims;
8+
using System.Security.Principal;
9+
using System.Threading.Tasks;
310
using Akka.Actor;
411
using Akka.Configuration;
512
using Akka.Serialization;
613
using Xunit;
714
using Akka.TestKit;
815
using Akka.TestKit.Xunit2;
916
using FluentAssertions;
17+
using Hyperion.Internal;
1018
using Xunit.Abstractions;
1119
using AkkaSerializer = Akka.Serialization.Serializer;
1220

@@ -72,6 +80,79 @@ public void Bugfix263_Akka_HyperionSerializer_should_serialize_ActorPath_list()
7280
deserialized.Destinations[0].Should().Be(deserialized.Destinations[1]);
7381
}
7482

83+
[Fact]
84+
public async Task CanDeserializeANaughtyTypeWhenAllowed()
85+
{
86+
var config = ConfigurationFactory.ParseString(@"
87+
akka {
88+
serialize-messages = on
89+
actor {
90+
serializers {
91+
hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
92+
}
93+
serialization-bindings {
94+
""System.Object"" = hyperion
95+
}
96+
serialization-settings.hyperion.disallow-unsafe-type = false
97+
}
98+
}");
99+
var system = ActorSystem.Create("unsafeSystem", config);
100+
101+
try
102+
{
103+
var serializer = system.Serialization.FindSerializerForType(typeof(DirectoryInfo));
104+
var di = new DirectoryInfo(@"c:\");
105+
106+
var serialized = serializer.ToBinary(di);
107+
var deserialized = serializer.FromBinary<DirectoryInfo>(serialized);
108+
}
109+
finally
110+
{
111+
await system.Terminate();
112+
}
113+
}
114+
115+
[Fact]
116+
public async Task CantDeserializeANaughtyTypeByDefault()
117+
{
118+
var config = ConfigurationFactory.ParseString(@"
119+
akka {
120+
serialize-messages = on
121+
actor {
122+
serializers {
123+
hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
124+
}
125+
serialization-bindings {
126+
""System.Object"" = hyperion
127+
}
128+
serialization-settings.hyperion.disallow-unsafe-type = true # this is the default value
129+
}
130+
}");
131+
var system = ActorSystem.Create("unsafeSystem", config);
132+
133+
try
134+
{
135+
var deserializer = system.Serialization.FindSerializerForType(typeof(DirectoryInfo));
136+
var di = new DirectoryInfo(@"c:\");
137+
138+
byte[] serialized;
139+
using (var stream = new MemoryStream())
140+
{
141+
var serializer = new Serializer(SerializerOptions.Default.WithDisallowUnsafeType(false));
142+
serializer.Serialize(di, stream);
143+
stream.Position = 0;
144+
serialized = stream.ToArray();
145+
}
146+
147+
var ex = Assert.Throws<SerializationException>(() => deserializer.FromBinary<DirectoryInfo>(serialized));
148+
ex.InnerException.Should().BeOfType<EvilDeserializationException>();
149+
}
150+
finally
151+
{
152+
await system.Terminate();
153+
}
154+
}
155+
75156
private class MyActor: ReceiveActor
76157
{
77158

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.IO;
3+
using BenchmarkDotNet.Attributes;
4+
using Hyperion.Internal;
5+
6+
namespace Hyperion.Benchmarks
7+
{
8+
[Config(typeof(HyperionConfig))]
9+
public class TypeRejectionBenchmark
10+
{
11+
private Serializer _serializer;
12+
private Stream _dangerousStream;
13+
14+
[GlobalSetup]
15+
public void Setup()
16+
{
17+
var di = new DirectoryInfo("C:\\Windows\\Windows32");
18+
var serializer = new Serializer(SerializerOptions.Default.WithDisallowUnsafeType(false));
19+
_dangerousStream = new MemoryStream();
20+
serializer.Serialize(di, _dangerousStream);
21+
22+
_serializer = new Serializer();
23+
}
24+
25+
[GlobalCleanup]
26+
public void Cleanup()
27+
{
28+
_dangerousStream.Dispose();
29+
}
30+
31+
[Benchmark]
32+
public void DeserializeDanger()
33+
{
34+
_dangerousStream.Position = 0;
35+
try
36+
{
37+
_serializer.Deserialize<DirectoryInfo>(_dangerousStream);
38+
}
39+
catch(EvilDeserializationException)
40+
{
41+
// no-op
42+
}
43+
}
44+
45+
}
46+
}

src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Update="FSharp.Core" Version="6.0.1" />
12+
<PackageReference Update="FSharp.Core" Version="6.0.3" />
1313
</ItemGroup>
1414

1515
</Project>

src/Hyperion.Tests/Hyperion.Tests.csproj

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,54 @@
1818
<DefineConstants>$(DefineConstants);NETFX</DefineConstants>
1919
</PropertyGroup>
2020

21-
2221
<ItemGroup Condition="'$(TargetFramework)' == '$(NetFrameworkTestVersion)'">
23-
<Reference Include="System.Drawing">
24-
<Private>true</Private>
25-
</Reference>
22+
<Reference Include="System.Web">
23+
<HintPath>./lib</HintPath>
24+
<Private>true</Private>
25+
</Reference>
26+
<Reference Include="System.Web.Mobile">
27+
<HintPath>./lib</HintPath>
28+
<Private>true</Private>
29+
</Reference>
30+
<Reference Include="System.Windows.Forms">
31+
<HintPath>./lib</HintPath>
32+
<Private>true</Private>
33+
</Reference>
34+
<Reference Include="PresentationFramework">
35+
<HintPath>./lib</HintPath>
36+
<Private>true</Private>
37+
</Reference>
38+
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf">
39+
<HintPath>./lib</HintPath>
40+
<Private>true</Private>
41+
</Reference>
42+
<Reference Include="System.Drawing.Design">
43+
<HintPath>./lib</HintPath>
44+
<Private>true</Private>
45+
</Reference>
46+
<Reference Include="System.Drawing">
47+
<HintPath>./lib</HintPath>
48+
<Private>true</Private>
49+
</Reference>
50+
<Reference Include="System.IdentityModel">
51+
<HintPath>./lib</HintPath>
52+
<Private>true</Private>
53+
</Reference>
54+
<Reference Include="System.Activities.Presentation">
55+
<HintPath>./lib</HintPath>
56+
<Private>true</Private>
57+
</Reference>
2658
</ItemGroup>
2759

60+
<ItemGroup Condition="'$(TargetFramework)' != '$(NetFrameworkTestVersion)'">
61+
<PackageReference Include="System.Management.Automation" Version="6.2.7" />
62+
</ItemGroup>
63+
2864
<ItemGroup>
2965
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
3066
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
3167
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
68+
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
3269
<PackageReference Include="xunit" Version="$(XunitVersion)" />
3370
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVersion)" />
3471
</ItemGroup>

0 commit comments

Comments
 (0)