diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-10 11:32:13 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-05-10 11:32:13 -0500 |
| commit | 6a6de665cd23a651a5fdb8df37034b0b07c93c98 (patch) | |
| tree | 0abaf11ff4f466867c86a4a08e5ae6110b4dcf0d /tests | |
| parent | e73ccbe4b6bd35449e88e261aa6bfb869952517c (diff) | |
| download | slskd-6a6de665cd23a651a5fdb8df37034b0b07c93c98.tar.gz | |
ensure traversal segments fail
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs b/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs index 1f12d787..9fa4d304 100644 --- a/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs +++ b/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs @@ -241,9 +241,11 @@ public class QueueDownloadBatchRequestTests } [Theory] - [InlineData("C:\\Music")] - [InlineData("/music")] - [InlineData("\\\\server\\share")] + [InlineData("C:\\Music")] // Windows absolute + [InlineData("C:/Music")] // Windows absolute, forward slash + [InlineData("/music")] // Unix absolute + [InlineData("/home/user/Music")] // Unix absolute, deep + [InlineData("\\\\server\\share")] // UNC public void AbsolutePath_Fails(string value) { var (isValid, results) = Validate(new EnqueueDownloadBatchOptions { Destination = value }); @@ -251,5 +253,19 @@ public class QueueDownloadBatchRequestTests Assert.Single(results); Assert.Equal("The Destination field must be a relative path.", results[0].ErrorMessage); } + + [Theory] + [InlineData("../escape")] // traversal prefix + [InlineData("./music")] // current-dir prefix + [InlineData("music/../other")] // traversal in middle + [InlineData("sub/../../escape")] // double traversal + [InlineData("music\\..")] // traversal via backslash + public void TraversalSegment_Fails(string value) + { + var (isValid, results) = Validate(new EnqueueDownloadBatchOptions { Destination = value }); + Assert.False(isValid); + Assert.Single(results); + Assert.Contains("traversal segments", results[0].ErrorMessage); + } } } |
