From 13662f0adec794483ecaff212d0018a8ac10b1e5 Mon Sep 17 00:00:00 2001 From: Dan Gidman Date: Thu, 26 May 2022 11:57:51 -0500 Subject: [PATCH 1/2] #129 DOTNET-117 add configuration option to skip capture of the username --- README.md | 15 +++++++++++++++ Src/StackifyLib/Config.cs | 13 +++++-------- Src/StackifyLib/StackifyError.cs | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 23423bc..0309ea1 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,21 @@ static void StackifyAPILogger_OnLogMessage(string data) } ``` +## Additional Settings + +These settings are available to further customize what information is captured and transmitted to Stackify. + +```xml + + + + + + + + +``` + ## Errors and Logs diff --git a/Src/StackifyLib/Config.cs b/Src/StackifyLib/Config.cs index 8a70f08..1b87ff2 100644 --- a/Src/StackifyLib/Config.cs +++ b/Src/StackifyLib/Config.cs @@ -62,6 +62,10 @@ public static void LoadSettings() CaptureErrorCookies = Get("Stackify.CaptureErrorCookies", bool.FalseString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + CaptureErrorUserName = Get("Stackify.CaptureErrorUserName", bool.TrueString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + + CaptureErrorPostdata = Get("Stackify.CaptureErrorPostdata", bool.FalseString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + ApiKey = Get("Stackify.ApiKey", ApiKey ?? string.Empty); AppName = Get("Stackify.AppName", AppName ?? string.Empty); @@ -183,21 +187,14 @@ public static void LoadSettings() public static bool CaptureErrorPostdata { get; set; } public static bool CaptureErrorHeaders { get; set; } = true; public static bool CaptureErrorCookies { get; set; } - + public static bool CaptureErrorUserName { get; set; } = true; public static string CaptureErrorSessionWhitelist { get; set; } - public static string CaptureErrorHeadersWhitelist { get; set; } - public static string CaptureErrorHeadersBlacklist { get; set; } = "cookie,authorization"; - public static string CaptureErrorCookiesWhitelist { get; set; } - public static string CaptureErrorCookiesBlacklist { get; set; } = ".ASPXAUTH"; - public static int Ec2InstanceMetadataUpdateThresholdMinutes { get; set; } = 60; - public static bool? IsEc2 { get; set; } - public static bool? ApiLog { get; set; } public static int LoggingJsonMaxFields { get; set; } = 50; diff --git a/Src/StackifyLib/StackifyError.cs b/Src/StackifyLib/StackifyError.cs index 72004f0..623fb53 100644 --- a/Src/StackifyLib/StackifyError.cs +++ b/Src/StackifyLib/StackifyError.cs @@ -153,7 +153,7 @@ private void Init() { WebRequestDetail = new WebRequestDetail(this); - if (HttpContext.Current.User != null && HttpContext.Current.User.Identity != null) + if (Config.CaptureErrorUserName && HttpContext.Current.User != null && HttpContext.Current.User.Identity != null) { UserName = HttpContext.Current.User.Identity.Name; } @@ -163,7 +163,7 @@ private void Init() #else WebRequestDetail = new WebRequestDetail(this); #endif - + //Fire event OnCaptureDetail?.Invoke(this); From a2a0d2841bd9c7695230ae89a027ebf635118a3c Mon Sep 17 00:00:00 2001 From: Dan Gidman Date: Thu, 26 May 2022 12:35:01 -0500 Subject: [PATCH 2/2] chore: Updating snk resolution so you can build locally --- Src/NLog.Targets.Stackify/Properties/AssemblyInfo.cs | 2 +- Src/StackifyLib.AspNetCore/Properties/AssemblyInfo.cs | 2 +- Src/StackifyLib.CoreLogger/Properties/AssemblyInfo.cs | 2 +- Src/StackifyLib.ELMAH/Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- Src/StackifyLib.log4net/Properties/AssemblyInfo.cs | 2 +- Src/StackifyLib/Properties/AssemblyInfo.cs | 2 +- azure-pipelines.yml | 11 ++++++++++- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Src/NLog.Targets.Stackify/Properties/AssemblyInfo.cs b/Src/NLog.Targets.Stackify/Properties/AssemblyInfo.cs index 1646ed0..3f64138 100644 --- a/Src/NLog.Targets.Stackify/Properties/AssemblyInfo.cs +++ b/Src/NLog.Targets.Stackify/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyKeyFileAttribute("..\\StackifyLib\\Netreo.snk")] +//[assembly: AssemblyKeyFile("..\\StackifyLib\\Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Src/StackifyLib.AspNetCore/Properties/AssemblyInfo.cs b/Src/StackifyLib.AspNetCore/Properties/AssemblyInfo.cs index a52c663..014c678 100644 --- a/Src/StackifyLib.AspNetCore/Properties/AssemblyInfo.cs +++ b/Src/StackifyLib.AspNetCore/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyCompany("Stackify")] [assembly: AssemblyProduct("StackifyLib.AspNetCore")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyKeyFileAttribute("..\\StackifyLib\\Netreo.snk")] +//[assembly: AssemblyKeyFile("..\\StackifyLib\\Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Src/StackifyLib.CoreLogger/Properties/AssemblyInfo.cs b/Src/StackifyLib.CoreLogger/Properties/AssemblyInfo.cs index 5afe4ba..85adde5 100644 --- a/Src/StackifyLib.CoreLogger/Properties/AssemblyInfo.cs +++ b/Src/StackifyLib.CoreLogger/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyCompany("Stackify")] [assembly: AssemblyProduct("StackifyLib.CoreLogger")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyKeyFileAttribute("..\\StackifyLib\\Netreo.snk")] +//[assembly: AssemblyKeyFile("..\\StackifyLib\\Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Src/StackifyLib.ELMAH/Properties/AssemblyInfo.cs b/Src/StackifyLib.ELMAH/Properties/AssemblyInfo.cs index e607fbe..a8f28e4 100644 --- a/Src/StackifyLib.ELMAH/Properties/AssemblyInfo.cs +++ b/Src/StackifyLib.ELMAH/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyKeyFileAttribute("..\\StackifyLib\\Netreo.snk")] +//[assembly: AssemblyKeyFile("..\\StackifyLib\\Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Src/StackifyLib.StackifyTraceListener/Properties/AssemblyInfo.cs b/Src/StackifyLib.StackifyTraceListener/Properties/AssemblyInfo.cs index 4e554df..386ec2f 100644 --- a/Src/StackifyLib.StackifyTraceListener/Properties/AssemblyInfo.cs +++ b/Src/StackifyLib.StackifyTraceListener/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyCompany("Stackify")] [assembly: AssemblyProduct("StackifyLib.StackifyTraceListener")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyKeyFileAttribute("..\\StackifyLib\\Netreo.snk")] +//[assembly: AssemblyKeyFile("..\\StackifyLib\\Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Src/StackifyLib.log4net/Properties/AssemblyInfo.cs b/Src/StackifyLib.log4net/Properties/AssemblyInfo.cs index cbc5376..fa73b27 100644 --- a/Src/StackifyLib.log4net/Properties/AssemblyInfo.cs +++ b/Src/StackifyLib.log4net/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyKeyFileAttribute("..\\StackifyLib\\Netreo.snk")] +//[assembly: AssemblyKeyFile("..\\StackifyLib\\Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/Src/StackifyLib/Properties/AssemblyInfo.cs b/Src/StackifyLib/Properties/AssemblyInfo.cs index 3059e67..ad7d288 100644 --- a/Src/StackifyLib/Properties/AssemblyInfo.cs +++ b/Src/StackifyLib/Properties/AssemblyInfo.cs @@ -13,7 +13,7 @@ [assembly: AssemblyCopyright("Copyright © 2018-2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyKeyFileAttribute("Netreo.snk")] +//[assembly: AssemblyKeyFile("Netreo.snk")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6a8893b..6338d45 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -43,7 +43,16 @@ steps: inputs: targetType: inline script: > - (Get-Content -path Src\StackifyLib\StackifyLib.csproj -Raw) -replace 'StackifyLib','StackifyLib.signed' | Set-Content -Path Src\StackifyLib\StackifyLib.csproj + (Get-Content -path Src\StackifyLib\StackifyLib.csproj -Raw) -replace 'StackifyLib','StackifyLib.signed' | Set-Content -Path Src\StackifyLib\StackifyLib.csproj -Encoding utf8 + + # note: the signing attribute here is commented out so we can build locally + - powershell: | + $filename = Get-ChildItem ".\src\*\AssemblyInfo.cs" -Recurse + $filename | %{ + (gc $_) -replace ([regex]::Escape("//[assembly: AssemblyKeyFile")), "[assembly: AssemblyKeyFile" | Set-Content $_.FullName -Encoding utf8 + } + displayName: Uncoment signing attribute + - task: PowerShell@2 displayName: 'Setup Code Signing' inputs: