From e159f6e4cfdea4ca432ddaa29743e79577a3662a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 10 Oct 2023 16:01:24 +0000 Subject: [PATCH] test: fix defect path traversal tests The test never actually tested what it claims to test because it did not properly insert separators before `..`. --- test/fixtures/permission/fs-traversal.js | 6 +++--- test/parallel/test-permission-fs-traversal-path.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/fixtures/permission/fs-traversal.js b/test/fixtures/permission/fs-traversal.js index 2c35fb90ed6c1a..4b983ba2890be6 100644 --- a/test/fixtures/permission/fs-traversal.js +++ b/test/fixtures/permission/fs-traversal.js @@ -8,9 +8,9 @@ const path = require('path'); const blockedFolder = process.env.BLOCKEDFOLDER; const allowedFolder = process.env.ALLOWEDFOLDER; -const traversalPath = allowedFolder + '../file.md'; -const traversalFolderPath = allowedFolder + '../folder'; -const bufferTraversalPath = Buffer.from(allowedFolder + '../file.md'); +const traversalPath = allowedFolder + '/../file.md'; +const traversalFolderPath = allowedFolder + '/../folder'; +const bufferTraversalPath = Buffer.from(allowedFolder + '/../file.md'); { assert.ok(process.permission.has('fs.read', allowedFolder)); diff --git a/test/parallel/test-permission-fs-traversal-path.js b/test/parallel/test-permission-fs-traversal-path.js index 547cd81c77cf18..d618c3e4f79879 100644 --- a/test/parallel/test-permission-fs-traversal-path.js +++ b/test/parallel/test-permission-fs-traversal-path.js @@ -18,7 +18,7 @@ const tmpdir = require('../common/tmpdir'); const file = fixtures.path('permission', 'fs-traversal.js'); const blockedFolder = tmpdir.path; -const allowedFolder = tmpdir.resolve('subdirectory/'); +const allowedFolder = tmpdir.resolve('subdirectory'); const commonPathWildcard = path.join(__filename, '../../common*'); {