From c922cc5dc617dd776d4523cbf62376821c5a4ad9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 19 Nov 2023 00:17:32 -0800 Subject: [PATCH] Always validate Custom Script path --- .../Notifications/CustomScript/CustomScript.cs | 8 -------- .../Notifications/CustomScript/CustomScriptSettings.cs | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index 1976904d7..e085b4165 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -363,14 +363,6 @@ namespace NzbDrone.Core.Notifications.CustomScript failures.Add(new NzbDroneValidationFailure("Path", "File does not exist")); } - foreach (var systemFolder in SystemFolders.GetSystemFolders()) - { - if (systemFolder.IsParentPath(Settings.Path)) - { - failures.Add(new NzbDroneValidationFailure("Path", $"Must not be a descendant of '{systemFolder}'")); - } - } - if (failures.Empty()) { try diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScriptSettings.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScriptSettings.cs index f4d4d7803..ce5a398ed 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScriptSettings.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScriptSettings.cs @@ -11,6 +11,7 @@ namespace NzbDrone.Core.Notifications.CustomScript public CustomScriptSettingsValidator() { RuleFor(c => c.Path).IsValidPath(); + RuleFor(c => c.Path).SetValidator(new SystemFolderValidator()).WithMessage("Must not be a descendant of '{systemFolder}'"); RuleFor(c => c.Arguments).Empty().WithMessage("Arguments are no longer supported for custom scripts"); } }