Skip to content

Commit 71c5095

Browse files
authored
Merge pull request #3614 from AElfProject/feature/whitelist-to-sdk
Add a new whitelist solution
2 parents 29143a2 + 94abd2a commit 71c5095

File tree

26 files changed

+688
-42
lines changed

26 files changed

+688
-42
lines changed

AElf.All.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.
385385
EndProject
386386
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.Core", "src\AElf.Kernel.FeatureDisable.Core\AElf.Kernel.FeatureDisable.Core.csproj", "{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}"
387387
EndProject
388+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Spec", "src\AElf.Sdk.CSharp.Spec\AElf.Sdk.CSharp.Spec.csproj", "{45A77C41-142E-4296-A14A-D53067EC8B75}"
389+
EndProject
390+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Internal", "src\AElf.Sdk.CSharp.Internal\AElf.Sdk.CSharp.Internal.csproj", "{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}"
391+
EndProject
388392
Global
389393
GlobalSection(SolutionConfigurationPlatforms) = preSolution
390394
Debug|Any CPU = Debug|Any CPU
@@ -1107,6 +1111,14 @@ Global
11071111
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
11081112
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
11091113
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.Build.0 = Release|Any CPU
1114+
{45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1115+
{45A77C41-142E-4296-A14A-D53067EC8B75}.Debug|Any CPU.Build.0 = Debug|Any CPU
1116+
{45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.ActiveCfg = Release|Any CPU
1117+
{45A77C41-142E-4296-A14A-D53067EC8B75}.Release|Any CPU.Build.0 = Release|Any CPU
1118+
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1119+
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1120+
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1121+
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E}.Release|Any CPU.Build.0 = Release|Any CPU
11101122
EndGlobalSection
11111123
GlobalSection(SolutionProperties) = preSolution
11121124
HideSolutionNode = FALSE
@@ -1301,5 +1313,7 @@ Global
13011313
{A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
13021314
{8C0D86A4-D1A7-4B61-AC44-755F5AC75D67} = {4E54480A-D155-43ED-9736-1A5BE7957211}
13031315
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
1316+
{45A77C41-142E-4296-A14A-D53067EC8B75} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
1317+
{A77380A7-E425-45A3-BF3F-F865DA4F3F4E} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
13041318
EndGlobalSection
13051319
EndGlobal

azure-pipelines.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Azure Pipelines configuration file
22
jobs:
3-
# - template: templates/build-template-window.yml
4-
# parameters:
5-
# parts: 3
6-
# n: 1
7-
# codecoverage: true
8-
# - template: templates/build-template-window.yml
9-
# parameters:
10-
# parts: 3
11-
# n: 2
12-
# codecoverage: false
13-
# - template: templates/build-template-window.yml
14-
# parameters:
15-
# parts: 3
16-
# n: 3
17-
# codecoverage: false
3+
# - template: templates/build-template-window.yml
4+
# parameters:
5+
# parts: 3
6+
# n: 1
7+
# codecoverage: true
8+
# - template: templates/build-template-window.yml
9+
# parameters:
10+
# parts: 3
11+
# n: 2
12+
# codecoverage: false
13+
# - template: templates/build-template-window.yml
14+
# parameters:
15+
# parts: 3
16+
# n: 3
17+
# codecoverage: false
1818
- template: templates/build-template-linux.yml
1919
parameters:
2020
parts: 3
@@ -40,9 +40,9 @@ jobs:
4040
parts: 3
4141
n: 2
4242
codecoverage: true
43-
# - template: templates/build-template-macos.yml
44-
# parameters:
45-
# parts: 3
46-
# n: 3
47-
# codecoverage: true
43+
# - template: templates/build-template-macos.yml
44+
# parameters:
45+
# parts: 3
46+
# n: 3
47+
# codecoverage: true
4848

nuget.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/>
5+
<add key="aelf" value="https://www.myget.org/F/aelf-project-dev/api/v3/index.json" protocolVersion="3"/>
46
<add key="Nuget Test" value="https://int.nugettest.org/api/v2" />
7+
<add key="nexus" value="https://nexus-poc.test.aelf.dev/repository/nuget-group/index.json" protocolVersion="3" />
58
</packageSources>
69
</configuration>

src/AElf.CSharp.CodeOps/AElf.CSharp.CodeOps.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.5.0" />
1212
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
13-
<PackageReference Include="Groth16.Net" Version="1.1.0" />
13+
<PackageReference Include="Groth16.Net" Version="1.1.2" />
1414
<PackageReference Include="Poseidon.Net" Version="0.1.1" />
1515
</ItemGroup>
1616

src/AElf.CSharp.CodeOps/Patchers/Module/CallAndBranchCounts/Patcher.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void Patch(ModuleDefinition module)
1717
return;
1818

1919
// ReSharper disable once IdentifierTypo
20-
var nmspace = module.Types.Single(m => m.BaseType is TypeDefinition).Namespace;
20+
var nmspace = module.Types.Where(IsContractType).Single().Namespace;
2121

2222
var proxyBuilder = new Patch(module, nmspace);
2323

@@ -28,6 +28,20 @@ public void Patch(ModuleDefinition module)
2828

2929
module.Types.Add(proxyBuilder.ObserverType);
3030
}
31+
private static bool IsContractType(TypeDefinition type)
32+
{
33+
if (type.FullName.StartsWith("AElf.Sdk.CSharp.CSharpSmartContract`1"))
34+
return true;
35+
if (type.BaseType is TypeDefinition baseType)
36+
return IsContractType(baseType);
37+
if(type.BaseType is GenericInstanceType baseType0)
38+
return IsContractType(baseType0);
39+
return false;
40+
}
41+
private static bool IsContractType(GenericInstanceType type)
42+
{
43+
return type.FullName.StartsWith("AElf.Sdk.CSharp.CSharpSmartContract`1");
44+
}
3145
}
3246

3347
internal class MethodPatcher

src/AElf.CSharp.CodeOps/Validators/Method/ArrayValidator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading;
55
using AElf.CSharp.Core;
6+
using AElf.Types;
67
using Mono.Cecil;
78
using Mono.Cecil.Cil;
89
using Volo.Abp.DependencyInjection;
@@ -24,7 +25,7 @@ public class ArrayValidator : IValidator<MethodDefinition>, ITransientDependency
2425
.LimitByTotalSize(typeof(decimal), sizeof(decimal))
2526
.LimitByTotalSize(typeof(char), sizeof(char))
2627
.LimitByTotalSize(typeof(String), 128) // Need to limit the size of strings by disallowing String.Concat
27-
28+
.LimitByTotalSize(typeof(BigIntValue), 128)
2829
// It isn't possible to estimate runtime sizes for below, so limit by count
2930
.LimitByCount(typeof(Type), 5)
3031
.LimitByCount(typeof(Object), 5) // Support object in Linq queries

src/AElf.CSharp.CodeOps/Validators/Module/ContractStructureValidator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ private bool IsBadStateField(FieldDefinition field)
231231
if (_allowedStateTypes.Contains(field.FieldType.FullName))
232232
return false;
233233

234+
if(field.FieldType.Resolve().BaseType.FullName == typeof(StructuredState).FullName)
235+
return false;
234236
// If not ContractReferenceState then it is not allowed
235237
return field.FieldType.Resolve().BaseType.FullName != typeof(ContractReferenceState).FullName;
236238
}

src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ private void WhitelistAssemblies(Whitelist whitelist)
4949
.Assembly(typeof(IMethod).Assembly, Trust.Full) // AElf.CSharp.Core
5050
.Assembly(typeof(SecretSharingHelper).Assembly, Trust.Partial) // AElf.Cryptography
5151
.Assembly(typeof(ISmartContractBridgeContext).Assembly, Trust.Full) // AElf.Kernel.SmartContract.Shared
52-
.Assembly(typeof(Groth16.Net.Verifier).Assembly, Trust.Full) // AElf.Cryptography.ECDSA
53-
.Assembly(typeof(Poseidon.Net.Poseidon).Assembly, Trust.Full)
5452
;
5553
}
5654

@@ -64,6 +62,15 @@ private void WhitelistSystemTypes(Whitelist whitelist)
6462
.Type("Func`1", Permission.Allowed) // Required for protobuf generated code
6563
.Type("Func`2", Permission.Allowed) // Required for protobuf generated code
6664
.Type("Func`3", Permission.Allowed) // Required for protobuf generated code
65+
.Type("Func`4", Permission.Allowed)
66+
.Type("ValueTuple`1", Permission.Allowed)
67+
.Type("ValueTuple`2", Permission.Allowed)
68+
.Type("ValueTuple`3", Permission.Allowed)
69+
.Type("ValueTuple`4", Permission.Allowed)
70+
.Type("ValueTuple`5", Permission.Allowed)
71+
.Type("ValueTuple`6", Permission.Allowed)
72+
.Type("ValueTuple`7", Permission.Allowed)
73+
.Type("ValueTuple`8", Permission.Allowed)
6774
.Type("Nullable`1", Permission.Allowed) // Required for protobuf generated code
6875
.Type(typeof(BitConverter), Permission.Denied, member => member
6976
.Member(nameof(BitConverter.GetBytes), Permission.Allowed))

src/AElf.Kernel.FeatureDisable.Core/AElf.Kernel.FeatureDisable.Core.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<Configuration>Release</Configuration>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
79
</PropertyGroup>
810

911
<ItemGroup>

src/AElf.Kernel.FeatureDisable/AElf.Kernel.FeatureDisable.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<Configuration>Release</Configuration>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
79
</PropertyGroup>
810

911
<ItemGroup>

0 commit comments

Comments
 (0)