mirror of
https://github.com/Readarr/Readarr
synced 2025-12-29 03:34:35 +01:00
Improve path validation for Custom Script notifications
This commit is contained in:
parent
f55fda9bac
commit
cbdc2c51c4
1 changed files with 22 additions and 11 deletions
|
|
@ -222,22 +222,33 @@ public override ValidationResult Test()
|
|||
failures.Add(new NzbDroneValidationFailure("Path", "File does not exist"));
|
||||
}
|
||||
|
||||
try
|
||||
foreach (var systemFolder in SystemFolders.GetSystemFolders())
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
environmentVariables.Add("Readarr_EventType", "Test");
|
||||
|
||||
var processOutput = ExecuteScript(environmentVariables);
|
||||
|
||||
if (processOutput.ExitCode != 0)
|
||||
if (systemFolder.IsParentPath(Settings.Path))
|
||||
{
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, $"Script exited with code: {processOutput.ExitCode}"));
|
||||
failures.Add(new NzbDroneValidationFailure("Path", $"Must not be a descendant of '{systemFolder}'"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
if (failures.Empty())
|
||||
{
|
||||
_logger.Error(ex);
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message));
|
||||
try
|
||||
{
|
||||
var environmentVariables = new StringDictionary();
|
||||
environmentVariables.Add("Readarr_EventType", "Test");
|
||||
|
||||
var processOutput = ExecuteScript(environmentVariables);
|
||||
|
||||
if (processOutput.ExitCode != 0)
|
||||
{
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, $"Script exited with code: {processOutput.ExitCode}"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex);
|
||||
failures.Add(new NzbDroneValidationFailure(string.Empty, ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
return new ValidationResult(failures);
|
||||
|
|
|
|||
Loading…
Reference in a new issue