From ef477cd8fc4cad2480f73400012f9519914ac55f Mon Sep 17 00:00:00 2001 From: chen-zimmer-px Date: Fri, 14 Jul 2023 07:00:07 +0000 Subject: [PATCH 1/4] fixed accept header name --- PerimeterXModule/Internals/PxBlock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PerimeterXModule/Internals/PxBlock.cs b/PerimeterXModule/Internals/PxBlock.cs index 51e4e12..a37503c 100644 --- a/PerimeterXModule/Internals/PxBlock.cs +++ b/PerimeterXModule/Internals/PxBlock.cs @@ -26,7 +26,7 @@ public bool IsJsonResponse(PxContext pxContext) { Dictionary headers = pxContext.GetHeadersAsDictionary(); string jsonHeader; - bool jsonHeaderExists = headers.TryGetValue("accept", out jsonHeader) || headers.TryGetValue("content-type", out jsonHeader); + bool jsonHeaderExists = headers.TryGetValue("Accept", out jsonHeader) || headers.TryGetValue("Content-Type", out jsonHeader); if (jsonHeaderExists) { string[] values = jsonHeader.Split(','); From 1f334c51ac52c82d5006338f0b4dee1286c0b17a Mon Sep 17 00:00:00 2001 From: chen-zimmer-px Date: Sun, 16 Jul 2023 09:10:38 +0000 Subject: [PATCH 2/4] Fixed issue with headers --- .../CredentialIntelligenceManager.cs | 2 +- PerimeterXModule/Internals/PxBlock.cs | 14 +++++++++++--- PerimeterXModule/Internals/PxContext.cs | 14 ++------------ PerimeterXModule/PxModule.cs | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/PerimeterXModule/Internals/CredentialsIntelligence/CredentialIntelligenceManager.cs b/PerimeterXModule/Internals/CredentialsIntelligence/CredentialIntelligenceManager.cs index 3cd0acc..1e27be5 100644 --- a/PerimeterXModule/Internals/CredentialsIntelligence/CredentialIntelligenceManager.cs +++ b/PerimeterXModule/Internals/CredentialsIntelligence/CredentialIntelligenceManager.cs @@ -100,7 +100,7 @@ private ExtractedCredentials HandleExtractCredentials(ExtractorObject extraction return null; } - Dictionary headers = pxContext.GetLowercaseHeadersAsDictionary(); + Dictionary headers = pxContext.lowercaseHttpHeaders; if (extractionDetails.SentThrough == "header") { diff --git a/PerimeterXModule/Internals/PxBlock.cs b/PerimeterXModule/Internals/PxBlock.cs index a37503c..4d487f1 100644 --- a/PerimeterXModule/Internals/PxBlock.cs +++ b/PerimeterXModule/Internals/PxBlock.cs @@ -24,9 +24,17 @@ public PxBlock(PxModuleConfigurationSection config) public bool IsJsonResponse(PxContext pxContext) { - Dictionary headers = pxContext.GetHeadersAsDictionary(); - string jsonHeader; - bool jsonHeaderExists = headers.TryGetValue("Accept", out jsonHeader) || headers.TryGetValue("Content-Type", out jsonHeader); + Dictionary headers = pxContext.lowercaseHttpHeaders; + string acceptHeader; + string contentTypeHeader; + bool jsonHeaderExistsInAccept = headers.TryGetValue("accept", out acceptHeader); + bool jsonHeaderExistsInContentType = headers.TryGetValue("content-type", out contentTypeHeader); + return DoesJsonExists(acceptHeader, jsonHeaderExistsInAccept) || DoesJsonExists(contentTypeHeader, jsonHeaderExistsInContentType); + + } + + private static bool DoesJsonExists(string jsonHeader, bool jsonHeaderExists) + { if (jsonHeaderExists) { string[] values = jsonHeader.Split(','); diff --git a/PerimeterXModule/Internals/PxContext.cs b/PerimeterXModule/Internals/PxContext.cs index 7d6b83d..1d0c799 100644 --- a/PerimeterXModule/Internals/PxContext.cs +++ b/PerimeterXModule/Internals/PxContext.cs @@ -53,6 +53,7 @@ public class PxContext public bool MonitorRequest { get; set; } public LoginCredentialsFields LoginCredentialsFields { get; set; } public string RequestId { get; set; } + public Dictionary lowercaseHttpHeaders; public PxContext(HttpContext context, PxModuleConfigurationSection pxConfiguration) { @@ -194,6 +195,7 @@ public PxContext(HttpContext context, PxModuleConfigurationSection pxConfigurati RedirectOnCustomUrl = pxConfiguration.RedirectOnCustomUrl; MonitorRequest = shouldMonitorRequest(context, pxConfiguration); + lowercaseHttpHeaders = GetLowercaseHeadersAsDictionary(); } private bool shouldMonitorRequest(HttpContext context, PxModuleConfigurationSection pxConfiguration) @@ -275,18 +277,6 @@ public string GetPxCookie() return PxCookies.ContainsKey(PxConstants.COOKIE_V3_PREFIX) ? PxCookies[PxConstants.COOKIE_V3_PREFIX] : PxCookies[PxConstants.COOKIE_V1_PREFIX]; } - public Dictionary GetHeadersAsDictionary() - { - Dictionary headersDictionary = new Dictionary(); - - if (Headers != null && Headers.Count() > 0) - { - headersDictionary = Headers.ToDictionary(header => header.Name, header => header.Value); - } - - return headersDictionary; - } - public Dictionary GetLowercaseHeadersAsDictionary() { Dictionary headersDictionary = new Dictionary(); diff --git a/PerimeterXModule/PxModule.cs b/PerimeterXModule/PxModule.cs index 9dab783..245da05 100644 --- a/PerimeterXModule/PxModule.cs +++ b/PerimeterXModule/PxModule.cs @@ -473,7 +473,7 @@ private void PostActivity(PxContext pxContext, string eventType, ActivityDetails SocketIP = pxContext.Ip, Url = pxContext.FullUrl, Details = details, - Headers = pxContext.GetHeadersAsDictionary(), + Headers = pxContext.lowercaseHttpHeaders, }; if (!string.IsNullOrEmpty(pxContext.Vid)) From dd3df87fa7322b1d1ec2f3931971f2327d822fbc Mon Sep 17 00:00:00 2001 From: chen-zimmer-px Date: Mon, 17 Jul 2023 06:24:26 +0000 Subject: [PATCH 3/4] Release version 3.2.1 --- CHANGELOG.md | 5 +++++ PerimeterXModule/Properties/AssemblyInfo.cs | 4 ++-- README.md | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1811e1f..a325af9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) +## [3.2.1] - 2023-08-17 +### Fixed +- Fixed advanced blocking response feature + + ## [3.2.0] - 2023-01-03 ### Added - Support for credentials intelligence protocols `v2` and `multistep_sso` diff --git a/PerimeterXModule/Properties/AssemblyInfo.cs b/PerimeterXModule/Properties/AssemblyInfo.cs index 66c8491..830556d 100644 --- a/PerimeterXModule/Properties/AssemblyInfo.cs +++ b/PerimeterXModule/Properties/AssemblyInfo.cs @@ -23,5 +23,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.2.0")] -[assembly: AssemblyFileVersion("3.2.0")] +[assembly: AssemblyVersion("3.2.1")] +[assembly: AssemblyFileVersion("3.2.1")] diff --git a/README.md b/README.md index dabedfa..ffb0a0f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [PerimeterX](http://www.perimeterx.com) ASP.NET SDK =================================================== -> Latest stable version: [v3.2.0](https://www.nuget.org/packages/PerimeterXModule/3.2.0) +> Latest stable version: [v3.2.1](https://www.nuget.org/packages/PerimeterXModule/3.2.1) Table of Contents ----------------- From 31deab17a4ecfb7adbba6d06c5e29f5f3e8b0c2c Mon Sep 17 00:00:00 2001 From: chen-zimmer-px Date: Mon, 17 Jul 2023 06:27:34 +0000 Subject: [PATCH 4/4] update the metadata file --- px_metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/px_metadata.json b/px_metadata.json index 10bc77b..dfd4d52 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -1,5 +1,5 @@ { - "version": "3.2.0", + "version": "3.2.1", "supported_features": [ "additional_activity_handler", "advanced_blocking_response",