Skip to content

Commit

Permalink
Merge pull request #238 from gigya/develop
Browse files Browse the repository at this point in the history
4.7.2
  • Loading branch information
daniellm authored Feb 14, 2019
2 parents 5187a80 + 191d5b7 commit c3f4a69
Show file tree
Hide file tree
Showing 53 changed files with 2,375 additions and 689 deletions.
179 changes: 147 additions & 32 deletions .paket/Paket.Restore.targets

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions Gigya.Microdot.Configuration/Gigya.Microdot.Configuration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Gigya.Microdot.Configuration</RootNamespace>
<AssemblyName>Gigya.Microdot.Configuration</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -20,9 +20,11 @@
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>3</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<DocumentationFile>bin\Debug\Gigya.Microdot.Configuration.xml</DocumentationFile>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -32,6 +34,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -94,7 +99,7 @@
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations">
<Paket>True</Paket>
Expand All @@ -111,7 +116,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Gigya.ServiceContract">
<HintPath>..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll</HintPath>
Expand All @@ -122,7 +127,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Metrics">
<HintPath>..\packages\Metrics.NET\lib\net45\Metrics.dll</HintPath>
Expand All @@ -133,7 +138,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -144,10 +149,24 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="mscorlib">
<Paket>True</Paket>
</Reference>
<Reference Include="System.ComponentModel.Annotations">
<HintPath>..\packages\System.ComponentModel.Annotations\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="System.Threading.Tasks.Dataflow">
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll</HintPath>
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
Expand Down
13 changes: 7 additions & 6 deletions Gigya.Microdot.Fakes/Gigya.Microdot.Fakes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Gigya.Microdot.Fakes</RootNamespace>
<AssemblyName>Gigya.Microdot.Fakes</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -20,9 +20,10 @@
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\Gigya.Microdot.Fakes.xml</DocumentationFile>
<NoWarn>1591;1573</NoWarn>
<NoWarn>
</NoWarn>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down Expand Up @@ -96,7 +97,7 @@
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Metrics">
<HintPath>..\packages\Metrics.NET\lib\net45\Metrics.dll</HintPath>
Expand All @@ -107,10 +108,10 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="System.Threading.Tasks.Dataflow">
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll</HintPath>
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
Expand Down
32 changes: 19 additions & 13 deletions Gigya.Microdot.Hosting/Gigya.Microdot.Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Gigya.Microdot.Hosting</RootNamespace>
<AssemblyName>Gigya.Microdot.Hosting</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkProfile />
Expand All @@ -25,7 +25,8 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591;1573;1587</NoWarn>
<NoWarn>1587</NoWarn>
<WarningLevel>3</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
Expand Down Expand Up @@ -90,7 +91,9 @@
<Compile Include="Validators\ServiceValidator.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="paket.references">
<SubType>Designer</SubType>
</None>
Expand Down Expand Up @@ -126,7 +129,7 @@
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Microsoft.CSharp">
<Paket>True</Paket>
Expand All @@ -152,7 +155,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Gigya.ServiceContract">
<HintPath>..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll</HintPath>
Expand All @@ -163,7 +166,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Metrics">
<HintPath>..\packages\Metrics.NET\lib\net45\Metrics.dll</HintPath>
Expand All @@ -174,7 +177,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -185,32 +188,35 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="System.Collections.Immutable">
<HintPath>..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll</HintPath>
<HintPath>..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="System.Threading.Tasks.Dataflow">
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll</HintPath>
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="mscorlib">
<Paket>True</Paket>
</Reference>
<Reference Include="System.ValueTuple">
<HintPath>..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
<HintPath>..\packages\System.ValueTuple\lib\net47\System.ValueTuple.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
Expand Down
8 changes: 4 additions & 4 deletions Gigya.Microdot.Hosting/HttpService/ServerRequestPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public interface IServerRequestPublisher
public class ServerRequestPublisher : IServerRequestPublisher
{
private readonly IEventPublisher<ServiceCallEvent> _eventPublisher;
private readonly IPropertiesMetadataPropertiesCache _metadataPropertiesCache;
private readonly IMembersToLogExtractor _membersToLogExtractor;
private readonly IServiceEndPointDefinition _serviceEndPointDefinition;

public ServerRequestPublisher(IEventPublisher<ServiceCallEvent> eventPublisher,
IPropertiesMetadataPropertiesCache metadataPropertiesCache,
IMembersToLogExtractor membersToLogExtractor,
IServiceEndPointDefinition serviceEndPointDefinition)
{
_eventPublisher = eventPublisher;
_metadataPropertiesCache = metadataPropertiesCache;
_membersToLogExtractor = membersToLogExtractor;
_serviceEndPointDefinition = serviceEndPointDefinition;
}

Expand Down Expand Up @@ -58,7 +58,7 @@ public void TryPublish(ServiceCallEvent callEvent, IEnumerable<DictionaryEntry>
var type = pair.Value?.GetType();
if (type?.IsClass==true)
{
var metaParams = _metadataPropertiesCache.ParseIntoParams(pair.Value);
var metaParams = _membersToLogExtractor.ExtractMembersToLog(pair.Value);

foreach (var metaParam in metaParams)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ private bool IsIrrelevantTypes(Type type)
return false;
}

private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string methodName, string paramName, Type type, Stack<string> path)
private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string methodName, string paramName, Type type, Stack<string> path, bool isGenericPayload = false)
{
if (type.IsClass == false || IsIrrelevantTypes(type))
return;

if (path.Count == 100)
throw new StackOverflowException($"In Method {methodName} {paramName} cuased for 'StackOverflowException' - Probably due to circular references.");

Type[] typeArguments = null;
if (type.IsGenericType)
typeArguments = type.GetGenericArguments();

foreach (var memberInfo in type.FindMembers(MemberTypes.Property | MemberTypes.Field, BindingFlags.Public | BindingFlags.Instance, null, null)
.Where(x => x is FieldInfo || (x is PropertyInfo propertyInfo) && propertyInfo.CanRead))
{
Expand All @@ -89,14 +93,23 @@ private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string metho
if (memberInfo.GetCustomAttribute(typeof(SensitiveAttribute)) != null || memberInfo.GetCustomAttribute(typeof(NonSensitiveAttribute)) != null)
if (!logFieldExists)
throw new ProgrammaticException($"The method '{methodName}' parameter '{paramName}' has a member '{string.Join(" --> ", path.Reverse())}' that is marked as [Sensitive] or [NonSensitive], but the method parameter is not marked with [LogFields]");
else if (path.Count > 1)
else if (IsInvalidAttributeLevelPlacement(isGenericPayload, path.Count))
throw new ProgrammaticException($"The method '{methodName}' parameter '{paramName}' has a member '{string.Join(" --> ", path.Reverse())}' that is marked as [Sensitive] or [NonSensitive], but only root-level members can be marked as such.");

Type memberType = memberInfo is PropertyInfo propertyInfo ? propertyInfo.PropertyType : ((FieldInfo)memberInfo).FieldType;
VerifyMisplacedSensitiveAttribute(logFieldExists, methodName, paramName, memberType, path);
var isGeneric = typeArguments != null && typeArguments.Contains(memberType);
VerifyMisplacedSensitiveAttribute(logFieldExists, methodName, paramName, memberType, path, isGeneric);

path.Pop();
}
}

private bool IsInvalidAttributeLevelPlacement(bool isGenericPayload, int pathCount)
{
if (isGenericPayload)
return pathCount > 2; //Allow only attributes on one level of generic payload
else
return pathCount > 1; //Allow only attributes on root level
}
}
}
4 changes: 2 additions & 2 deletions Gigya.Microdot.Hosting/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
7 changes: 4 additions & 3 deletions Gigya.Microdot.Interfaces/Gigya.Microdot.Interfaces.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Gigya.Microdot.Interfaces</RootNamespace>
<AssemblyName>Gigya.Microdot.Interfaces</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -20,8 +20,9 @@
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\Gigya.Microdot.Interfaces.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -82,7 +83,7 @@
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Gigya.Microdot.Logging.NLog</RootNamespace>
<AssemblyName>Gigya.Microdot.Logging.NLog</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -19,7 +20,7 @@
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\Gigya.Microdot.Logging.NLog.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down Expand Up @@ -66,7 +67,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Ninject">
<HintPath>..\packages\Ninject\lib\net45\Ninject.dll</HintPath>
Expand All @@ -77,7 +78,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'">
<ItemGroup>
<Reference Include="Microsoft.CSharp">
<Paket>True</Paket>
Expand Down
Loading

0 comments on commit c3f4a69

Please sign in to comment.