Improve path validation for Custom Script notifications

pull/1594/head
Qstick 3 years ago
parent f55fda9bac
commit cbdc2c51c4

@ -222,6 +222,16 @@ namespace NzbDrone.Core.Notifications.CustomScript
failures.Add(new NzbDroneValidationFailure("Path", "File does not exist")); 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 try
{ {
var environmentVariables = new StringDictionary(); var environmentVariables = new StringDictionary();
@ -239,6 +249,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
_logger.Error(ex); _logger.Error(ex);
failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message)); failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message));
} }
}
return new ValidationResult(failures); return new ValidationResult(failures);
} }

Loading…
Cancel
Save