From 5344842690bbb4deb131cbc6321dd705b7b68094 Mon Sep 17 00:00:00 2001 From: Martijn Vos Date: Mon, 30 Dec 2024 12:49:30 +0100 Subject: [PATCH 1/5] Update System.Text.Json preventing critical vulnerability --- CHANGELOG.md | 4 ++++ CM.Text/CM.Text.csproj | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f272309..dbc2eb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.10.0] - TBD +### Changed +- Updated `System.Text.Json` to 8.0.5 fixing a [high impact security vulnerability](https://github.com/advisories/GHSA-hh2w-p6rv-4g7w) + ## [2.9.0] - 2024-06-20 ### Changed - New global messaging endpoint diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 059764a..49be016 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -63,7 +63,7 @@ - + From 91243e7cb047c29c9e27b2c4e18c433440e75aac Mon Sep 17 00:00:00 2001 From: Martijn Vos Date: Mon, 30 Dec 2024 12:50:01 +0100 Subject: [PATCH 2/5] Add polymorphic type discriminators on IRichMessage for deserialization --- CHANGELOG.md | 3 +++ .../Model/MultiChannel/IRichMessage.cs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbc2eb4..990a727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [2.10.0] - TBD +### Added +- Polymorphic type discriminators on IRichMessage for deserialization + ### Changed - Updated `System.Text.Json` to 8.0.5 fixing a [high impact security vulnerability](https://github.com/advisories/GHSA-hh2w-p6rv-4g7w) diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs index b773e05..cc1b6be 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs @@ -8,14 +8,14 @@ namespace CM.Text.BusinessMessaging.Model.MultiChannel /// Requires a json derived type for serialization to work /// [PublicAPI] - [JsonDerivedType(typeof(MediaMessage))] - [JsonDerivedType(typeof(ApplePayRequest))] - [JsonDerivedType(typeof(CarouselMessage))] - [JsonDerivedType(typeof(ContactMessage))] - [JsonDerivedType(typeof(LocationPushMessage))] - [JsonDerivedType(typeof(TemplateMessage))] - [JsonDerivedType(typeof(TextMessage))] - [JsonDerivedType(typeof(WhatsAppInteractiveMessage))] + [JsonDerivedType(typeof(MediaMessage), nameof(MediaMessage))] + [JsonDerivedType(typeof(ApplePayRequest), nameof(ApplePayRequest))] + [JsonDerivedType(typeof(CarouselMessage), nameof(CarouselMessage))] + [JsonDerivedType(typeof(ContactMessage), nameof(ContactMessage))] + [JsonDerivedType(typeof(LocationPushMessage), nameof(LocationPushMessage))] + [JsonDerivedType(typeof(TemplateMessage), nameof(TemplateMessage))] + [JsonDerivedType(typeof(TextMessage), nameof(TextMessage))] + [JsonDerivedType(typeof(WhatsAppInteractiveMessage), nameof(WhatsAppInteractiveMessage))] public interface IRichMessage { } From 55ff0b01863ea2ba24e8a12e71475dd8a19fb9a1 Mon Sep 17 00:00:00 2001 From: Martijn Vos Date: Mon, 30 Dec 2024 14:11:42 +0100 Subject: [PATCH 3/5] Add basic tests for serialization and deserialization of a Text message --- CM.Text.Tests/DeserializationTests.cs | 23 +++++++++++++++++++++++ CM.Text.Tests/SerializationTests.cs | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 CM.Text.Tests/DeserializationTests.cs create mode 100644 CM.Text.Tests/SerializationTests.cs diff --git a/CM.Text.Tests/DeserializationTests.cs b/CM.Text.Tests/DeserializationTests.cs new file mode 100644 index 0000000..ba5e6f7 --- /dev/null +++ b/CM.Text.Tests/DeserializationTests.cs @@ -0,0 +1,23 @@ +using System.Text.Json; +using CM.Text.BusinessMessaging.Model.MultiChannel; +using FluentAssertions; + +namespace CM.Text.Tests +{ + [TestClass] + public class DeserializationTests + { + [TestMethod] + public void DeserializeTextTest() + { + var textMessage = "{\"$type\":\"TextMessage\",\"text\":\"testing correct deserialization\",\"tag\":null,\"suggestions\":null}"; + var deserialized = JsonSerializer.Deserialize(textMessage); + + deserialized.Should().BeOfType(); + var deserializedTextMessage = deserialized as TextMessage; + deserializedTextMessage!.Text.Should().Be("testing correct deserialization"); + } + } +} + + diff --git a/CM.Text.Tests/SerializationTests.cs b/CM.Text.Tests/SerializationTests.cs new file mode 100644 index 0000000..8b35aa0 --- /dev/null +++ b/CM.Text.Tests/SerializationTests.cs @@ -0,0 +1,20 @@ +using System.Text.Json; +using CM.Text.BusinessMessaging.Model.MultiChannel; +using FluentAssertions; + +namespace CM.Text.Tests +{ + [TestClass] + public class SerializationTests + { + [TestMethod] + public void SerializeTextTest() + { + var textMessage = new TextMessage("testing correct serialization"); + var serialized= JsonSerializer.Serialize(textMessage); + + serialized.Should().NotBeNullOrWhiteSpace(); + serialized.Should().Contain("\"$type\":\"TextMessage\""); + } + } +} From ed40d09ae6cf08e7edf3022bb80825262d39e501 Mon Sep 17 00:00:00 2001 From: Martijn Vos Date: Mon, 30 Dec 2024 14:16:36 +0100 Subject: [PATCH 4/5] Update 2.9.0 version references in .csproj to 2.10.0 --- CM.Text/CM.Text.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 49be016..a9ff480 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -13,12 +13,12 @@ LICENSE icon.png $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - 2.9.0 + 2.10.0 https://github.com/cmdotcom/text-sdk-dotnet en true - 2.9.0 - 2.9.0 + 2.10.0 + 2.10.0 True From 65428d09db9f28fda7bb4922c08f242b5ff2f96d Mon Sep 17 00:00:00 2001 From: Martijn Vos Date: Mon, 30 Dec 2024 14:32:45 +0100 Subject: [PATCH 5/5] Change TBD date in CHANGELOG to today --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 990a727..2a2af72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.10.0] - TBD +## [2.10.0] - 2024-12-30 ### Added - Polymorphic type discriminators on IRichMessage for deserialization