From 4bc776df67131c5ea888de6184b2f3f455baebc7 Mon Sep 17 00:00:00 2001 From: Esteban Date: Thu, 29 Oct 2026 16:50:00 -0600 Subject: [PATCH 1/2] my first contribution --- .../test-permission-fs-read-entrypoint.js | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-permission-fs-read-entrypoint.js b/test/parallel/test-permission-fs-read-entrypoint.js index f0182dce6454..22421ee09aae 100644 --- a/test/parallel/test-permission-fs-read-entrypoint.js +++ b/test/parallel/test-permission-fs-read-entrypoint.js @@ -21,11 +21,24 @@ const file = fixtures.path('permission', 'hello-world.js'); const simpleLoader = fixtures.path('permission', 'simple-loader.js'); const fsReadLoader = fixtures.path('permission', 'fs-read-loader.js'); -[ - '', - simpleLoader, - fsReadLoader, -].forEach((arg0) => { +//[ + //'', + //simpleLoader, + //fsReadLoader, +//].forEach((arg0) => { + //const { status, stderr } = spawnSync( + //process.execPath, + //[ + //arg0 !== '' ? '-r' : '', + //arg0, + //'--permission', + //file, + //], + //); + //assert.strictEqual(status, 0, `${arg0} Error: ${stderr.toString()}`); +//}); + +for (const arg0 of ['', simpleLoader, fsReadLoader]) { const { status, stderr } = spawnSync( process.execPath, [ @@ -36,15 +49,28 @@ const fsReadLoader = fixtures.path('permission', 'fs-read-loader.js'); ], ); assert.strictEqual(status, 0, `${arg0} Error: ${stderr.toString()}`); -}); - +} // When the code is read from stdin there is no entrypoint, so no implicit // read access should be granted (in particular, not to the cwd). +//tmpdir.refresh(); +//[ + //['--permission'], + //['--permission', '-'], +//].forEach((args) => { + //const { status, stdout, stderr } = spawnSync(process.execPath, args, { + //cwd: tmpdir.path, + //input: 'console.log(process.permission.has("fs.read", ' + + // 'require("path").join(process.cwd(), "x")))', + //}); + //assert.strictEqual(status, 0, `${args} Error: ${stderr.toString()}`); + //assert.strictEqual(stdout.toString().trim(), 'false'); +//}); + tmpdir.refresh(); -[ +for (const args of [ ['--permission'], ['--permission', '-'], -].forEach((args) => { +]) { const { status, stdout, stderr } = spawnSync(process.execPath, args, { cwd: tmpdir.path, input: 'console.log(process.permission.has("fs.read", ' + @@ -52,4 +78,4 @@ tmpdir.refresh(); }); assert.strictEqual(status, 0, `${args} Error: ${stderr.toString()}`); assert.strictEqual(stdout.toString().trim(), 'false'); -}); +} From 6907756892e9dedb5e1084c83a8dba35e8831dfc Mon Sep 17 00:00:00 2001 From: Esteban Date: Thu, 29 Oct 2026 17:06:33 -0600 Subject: [PATCH 2/2] test: replace foreach with for of Signed-off-by: Esteban --- .../test-permission-fs-read-entrypoint.js | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/test/parallel/test-permission-fs-read-entrypoint.js b/test/parallel/test-permission-fs-read-entrypoint.js index 22421ee09aae..ba699ebf9e25 100644 --- a/test/parallel/test-permission-fs-read-entrypoint.js +++ b/test/parallel/test-permission-fs-read-entrypoint.js @@ -21,22 +21,6 @@ const file = fixtures.path('permission', 'hello-world.js'); const simpleLoader = fixtures.path('permission', 'simple-loader.js'); const fsReadLoader = fixtures.path('permission', 'fs-read-loader.js'); -//[ - //'', - //simpleLoader, - //fsReadLoader, -//].forEach((arg0) => { - //const { status, stderr } = spawnSync( - //process.execPath, - //[ - //arg0 !== '' ? '-r' : '', - //arg0, - //'--permission', - //file, - //], - //); - //assert.strictEqual(status, 0, `${arg0} Error: ${stderr.toString()}`); -//}); for (const arg0 of ['', simpleLoader, fsReadLoader]) { const { status, stderr } = spawnSync( @@ -53,18 +37,7 @@ for (const arg0 of ['', simpleLoader, fsReadLoader]) { // When the code is read from stdin there is no entrypoint, so no implicit // read access should be granted (in particular, not to the cwd). //tmpdir.refresh(); -//[ - //['--permission'], - //['--permission', '-'], -//].forEach((args) => { - //const { status, stdout, stderr } = spawnSync(process.execPath, args, { - //cwd: tmpdir.path, - //input: 'console.log(process.permission.has("fs.read", ' + - // 'require("path").join(process.cwd(), "x")))', - //}); - //assert.strictEqual(status, 0, `${args} Error: ${stderr.toString()}`); - //assert.strictEqual(stdout.toString().trim(), 'false'); -//}); + tmpdir.refresh(); for (const args of [