Skip to content

Commit 0c56962

Browse files
authored
test: fix defect path traversal tests
The test never actually tested what it claims to test because it did not properly insert separators before `..`. PR-URL: #50124 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent f09a50c commit 0c56962

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

test/fixtures/permission/fs-traversal.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ path.resolve = (s) => s;
1212

1313
const blockedFolder = process.env.BLOCKEDFOLDER;
1414
const allowedFolder = process.env.ALLOWEDFOLDER;
15-
const traversalPath = allowedFolder + '../file.md';
16-
const traversalFolderPath = allowedFolder + '../folder';
17-
const bufferTraversalPath = Buffer.from(allowedFolder + '../file.md');
15+
const traversalPath = allowedFolder + '/../file.md';
16+
const traversalFolderPath = allowedFolder + '/../folder';
17+
const bufferTraversalPath = Buffer.from(traversalPath);
1818
const uint8ArrayTraversalPath = new TextEncoder().encode(traversalPath);
1919

2020
{

test/parallel/test-permission-fs-traversal-path.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const tmpdir = require('../common/tmpdir');
1818

1919
const file = fixtures.path('permission', 'fs-traversal.js');
2020
const blockedFolder = tmpdir.path;
21-
const allowedFolder = tmpdir.resolve('subdirectory/');
21+
const allowedFolder = tmpdir.resolve('subdirectory');
2222
const commonPathWildcard = path.join(__filename, '../../common*');
2323

2424
{

0 commit comments

Comments
 (0)