diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs index 63b940d646..db32cc1c2b 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs @@ -8,8 +8,6 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Components.StaticFiles { /// @@ -24,7 +22,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// Path to the destination folder. /// The for the operation. /// A resulting in the if any. - ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken); + ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken); /// /// Symlinks all directories in the GameData directory to . @@ -41,7 +39,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in an of the s for the items in the directory. and will both be . will be returned if the operation failed due to access contention. - ValueTask> ListDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Reads a given . @@ -50,7 +48,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in the of the file. will be returned if the operation failed due to access contention. - ValueTask Read(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask Read(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Create an empty directory at . @@ -59,7 +57,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. Usage may result in partial writes. /// A resulting in if the directory already existed, otherwise. will be returned if the operation failed due to access contention. - ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Attempt to delete an empty directory at . @@ -68,7 +66,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in if the directory was empty and deleted, otherwise. will be returned if the operation failed due to access contention. - ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Writes to a given . @@ -78,6 +76,6 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The hash any existing file must match in order for the write to succeed. /// The for the operation. Usage may result in partial writes. /// A resulting in the updated and associated writing . will be returned if the operation failed due to access contention. - ValueTask Write(string configurationRelativePath, ISystemIdentity systemIdentity, string previousHash, CancellationToken cancellationToken); + ValueTask Write(string configurationRelativePath, ISystemIdentity? systemIdentity, string? previousHash, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs index 1df1fbc907..8232be095c 100644 --- a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs +++ b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs @@ -84,7 +84,7 @@ namespace Tgstation.Server.Host.Controllers var newFile = await instance .Configuration .Write( - model.Path, + model.Path!, systemIdentity, model.LastReadHash, cancellationToken); @@ -240,6 +240,9 @@ namespace Tgstation.Server.Host.Controllers { ArgumentNullException.ThrowIfNull(model); + if (model.Path == null) + return BadRequest(new ErrorMessageResponse(ErrorCode.ModelValidationFailure)); + if (ForbidDueToModeConflicts(model.Path, out var systemIdentity)) return Forbid();