From c310a97b6372c9908757be532da5aba0a8a5e196 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 1 Jul 2023 15:11:35 -0500 Subject: refactor file service to prevent relative navigation --- src/slskd/Files/IFileService.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/slskd/Files/IFileService.cs') diff --git a/src/slskd/Files/IFileService.cs b/src/slskd/Files/IFileService.cs index 2d4d66f5..63b5f1a3 100644 --- a/src/slskd/Files/IFileService.cs +++ b/src/slskd/Files/IFileService.cs @@ -20,6 +20,7 @@ namespace slskd.Files using System; using System.Collections.Generic; using System.IO; + using System.Security; using System.Threading.Tasks; using OneOf; @@ -35,12 +36,15 @@ namespace slskd.Files /// Returns a dictionary keyed on directory name and containing a result for each specified directory. Exceptions are /// contained in the result, and are not thrown. /// - /// The root directory. /// The directories to delete. /// The operation context. + /// Thrown if any of the specified directories have a relative path. + /// + /// Thrown if any of the directories is an exact match for an application-controlled directory. + /// /// Thrown if a specified directory does not exist. - /// Thrown if a specified directory is restricted. - Task>> DeleteDirectoriesAsync(string rootDirectory, params string[] directories); + /// Thrown if a specified directory is restricted. + Task>> DeleteDirectoriesAsync(params string[] directories); /// /// Deletes the specified . @@ -49,22 +53,22 @@ namespace slskd.Files /// Returns a dictionary keyed on directory name and containing a result for each specified directory. Exceptions are /// contained in the result, and are not thrown. /// - /// The root directory. /// The list of files to delete. /// The operation context. + /// Thrown if any of the specified files have a relative path. /// Thrown if a specified file does not exist. - /// Thrown if a specified file is restricted. - Task>> DeleteFilesAsync(string rootDirectory, params string[] files); + /// Thrown if a specified file is restricted. + Task>> DeleteFilesAsync(params string[] files); /// - /// Lists the contents in the specified , optionally applying the specified . + /// Lists the contents in the specified , optionally applying the specified . /// - /// The root directory. - /// An optional subdirectory from which to start the listing. + /// The directory from which to start the listing. /// Optional enumeration options to apply. /// The list of found contents. + /// Thrown if the specified directory has a relative path. /// Thrown if the specified directory does not exist. - /// Thrown if the specified root directory is restricted. - Task ListContentsAsync(string rootDirectory, string parentDirectory = null, EnumerationOptions enumerationOptions = null); + /// Thrown if the specified root directory is restricted. + Task ListContentsAsync(string directory, EnumerationOptions enumerationOptions = null); } } \ No newline at end of file -- cgit v1.2.3