From af4ff004768800440de3c06af8aa7bd2b1f4cdcd Mon Sep 17 00:00:00 2001 From: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:26:29 +0100 Subject: [PATCH] Fixed: Telegram log message including token (cherry picked from commit a7cb264cc8013d9a56aee7d5e41acfd76cde5f96) --- .../InstrumentationTests/CleanseLogMessageFixture.cs | 4 ++++ src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs index 8f9db6b06..3ee34afef 100644 --- a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs +++ b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs @@ -101,6 +101,10 @@ namespace NzbDrone.Common.Test.InstrumentationTests [TestCase(@"https://discord.com/api/webhooks/mySecret")] [TestCase(@"https://discord.com/api/webhooks/mySecret/01233210")] + // Telegram + [TestCase(@"https://api.telegram.org/bot1234567890:mySecret/sendmessage: chat_id=123456&parse_mode=HTML&text=")] + [TestCase(@"https://api.telegram.org/bot1234567890:mySecret/")] + public void should_clean_message(string message) { var cleansedMessage = CleanseLogMessage.Cleanse(message); diff --git a/src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs b/src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs index afa9154ce..f619497d3 100644 --- a/src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs +++ b/src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs @@ -63,7 +63,10 @@ namespace NzbDrone.Common.Instrumentation new (@",""rss[- _]?key"":""(?[^&=]+?)"",", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Discord - new (@"discord.com/api/webhooks/((?[\w-]+)/)?(?[\w-]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase) + new (@"discord.com/api/webhooks/((?[\w-]+)/)?(?[\w-]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase), + + // Telegram + new (@"api.telegram.org/bot(?[\d]+):(?[\w-]+)/", RegexOptions.Compiled | RegexOptions.IgnoreCase) }; private static readonly Regex CleanseRemoteIPRegex = new (@"(?:Auth-\w+(?