-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
lib,permission: ignore internalModuleStat on module loading #55797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1 @@ | ||||||||
require('./required-module'); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1 @@ | ||||||||
import './required-module.mjs'; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1 @@ | ||||||||
console.log('ok'); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1 @@ | ||||||||
console.log('ok'); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
common.skipIfWorker(); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
const assert = require('node:assert'); | ||
const { spawnSync } = require('node:child_process'); | ||
|
||
{ | ||
const mainModule = fixtures.path('permission', 'main-module.js'); | ||
const requiredModule = fixtures.path('permission', 'required-module.js'); | ||
const { status, stdout, stderr } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-read', mainModule, | ||
'--allow-fs-read', requiredModule, | ||
mainModule, | ||
] | ||
); | ||
|
||
assert.strictEqual(status, 0, stderr.toString()); | ||
assert.strictEqual(stdout.toString(), 'ok\n'); | ||
} | ||
|
||
{ | ||
// When required module is not passed as allowed path | ||
const mainModule = fixtures.path('permission', 'main-module.js'); | ||
const { status, stderr } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-read', mainModule, | ||
mainModule, | ||
] | ||
); | ||
|
||
assert.strictEqual(status, 1, stderr.toString()); | ||
assert.match(stderr.toString(), /Error: Access to this API has been restricted/); | ||
} | ||
|
||
{ | ||
// ESM loader test | ||
const mainModule = fixtures.path('permission', 'main-module.mjs'); | ||
const requiredModule = fixtures.path('permission', 'required-module.mjs'); | ||
const { status, stdout, stderr } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-read', mainModule, | ||
'--allow-fs-read', requiredModule, | ||
mainModule, | ||
] | ||
); | ||
|
||
assert.strictEqual(status, 0, stderr.toString()); | ||
assert.strictEqual(stdout.toString(), 'ok\n'); | ||
} | ||
|
||
{ | ||
// When required module is not passed as allowed path (ESM) | ||
const mainModule = fixtures.path('permission', 'main-module.mjs'); | ||
const { status, stderr } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-read', mainModule, | ||
mainModule, | ||
] | ||
); | ||
|
||
assert.strictEqual(status, 1, stderr.toString()); | ||
assert.match(stderr.toString(), /Error: Access to this API has been restricted/); | ||
} |
This comment was marked as abuse.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.