From d1f2a8a9486471f4986da2fa16d5439ccf0426e1 Mon Sep 17 00:00:00 2001 From: Chris <1967906+psylenced@users.noreply.github.com> Date: Mon, 17 Oct 2022 02:42:33 +1100 Subject: [PATCH] Fixed: Cleanse Discord Webhook URLs Closes #5169 --- .../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 f01a72912..07f19ca6e 100644 --- a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs +++ b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs @@ -75,6 +75,10 @@ namespace NzbDrone.Common.Test.InstrumentationTests // Webhooks - Notifiarr [TestCase(@"https://xxx.yyy/api/v1/notification/sonarr/9pr04sg6-0123-3210-imav-eql2tyu8xyui")] + // Discord + [TestCase(@"https://discord.com/api/webhooks/mySecret")] + [TestCase(@"https://discord.com/api/webhooks/mySecret/01233210")] + 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 2c56d6929..abb1bdc83 100644 --- a/src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs +++ b/src/NzbDrone.Common/Instrumentation/CleanseLogMessage.cs @@ -50,7 +50,10 @@ namespace NzbDrone.Common.Instrumentation // Webhooks // Notifiarr - new Regex(@"api/v[0-9]/notification/sonarr/(?[\w-]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase) + new Regex(@"api/v[0-9]/notification/sonarr/(?[\w-]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase), + + // Discord + new Regex(@"discord.com/api/webhooks/((?[\w-]+)/)?(?[\w-]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase) }; private static readonly Regex CleanseRemoteIPRegex = new Regex(@"(?:Auth-\w+(?