mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
3a0968db43
This improves Permission Model usage when allowing read access to specifi modules. To achieve that, the permission model check on internalModuleStat has been removed meaning that on module loading, uv_fs_stat is performed on files and folders even when the permission model is enabled. Although a uv_fs_stat is performed, reading/executing the module will still pass by the permission model check. Without this PR when an app tries to --allow-fs-read=./a.js --allow-fs-read=./b.js where `a` attempt to load b, it will fails as it reads $pwd and no permission has been given to this path. PR-URL: https://github.com/nodejs/node/pull/55797 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
23 lines
767 B
JavaScript
23 lines
767 B
JavaScript
// Flags: --expose-internals --experimental-permission --allow-fs-read=test/common* --allow-fs-read=tools* --allow-fs-read=test/parallel* --allow-child-process
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
common.skipIfWorker();
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('no crypto');
|
|
}
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const blockedFile = fixtures.path('permission', 'deny', 'protected-file.md');
|
|
const internalFsBinding = internalBinding('fs');
|
|
|
|
// Run this inside a for loop to trigger the fast API
|
|
for (let i = 0; i < 10_000; i++) {
|
|
// internalModuleStat does not use permission model.
|
|
// doesNotThrow
|
|
internalFsBinding.internalModuleStat(internalFsBinding, blockedFile);
|
|
}
|