Skip to content

Commit

Permalink
added file paths variety
Browse files Browse the repository at this point in the history
  • Loading branch information
hr2904 committed Jun 14, 2024
1 parent 33aa9c2 commit a365a1c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public void testValidateFilePath() {
// Array of test cases, each containing the file path and the expected boolean result
Object[][] testCases = {
{"/var/app/allowed/file.txt", true, "Should return true for a valid path within the allowed directory."},
{"/var/app/allowed/../notallowed/file.txt", false, "Should return false for a path attempting directory traversal."},
{"/tmp/../notallowed/file.txt", false, "Should return false for a path attempting directory traversal."},
{"/var/app/allowed/./file.txt", false, "Should return false for a path with relative current directory notation."},
{"/var/app/allowed/.\\file.txt", false, "Should return false for a path with mixed slash types potentially bypassing checks."},
{"var/app/allowed/file.txt", false, "Should return false for non-absolute paths."},
{"/Users/username/repos/repo0/.\\file.txt", false, "Should return false for a path with mixed slash types potentially bypassing checks."},
{"tmp/file.txt", false, "Should return false for non-absolute paths."},
{"/var/app/allowed/..\\file.txt", false, "Should return false for paths with unusual characters aiming to navigate directories."},
{"/var/app/allowed/%2e%2e/notallowed/file.txt", false, "Should return false for paths with URL-encoded traversal sequences."},
{"/Users/username/repos/repo0/%2e%2e/notallowed/file.txt", false, "Should return false for paths with URL-encoded traversal sequences."},
{"/var/app/allowed/\0file.txt", false, "Should return false for paths that cause exceptions, like those containing null bytes."}
};

Expand Down

0 comments on commit a365a1c

Please sign in to comment.