mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
src,lib: stabilize permission model
Move permission model from 1.1 (Active Development) to 2.0 (Stable). PR-URL: https://github.com/nodejs/node/pull/56201 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
parent
33f0f1656b
commit
be04d06488
53 changed files with 143 additions and 147 deletions
|
@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, {
|
||||||
concurrent: [1, 10],
|
concurrent: [1, 10],
|
||||||
}, {
|
}, {
|
||||||
flags: [
|
flags: [
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read=*',
|
'--allow-fs-read=*',
|
||||||
'--allow-fs-write=*',
|
'--allow-fs-write=*',
|
||||||
'--allow-child-process',
|
'--allow-child-process',
|
||||||
|
|
|
@ -11,7 +11,7 @@ const rootPath = path.resolve(__dirname, '../../..');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
flags: [
|
flags: [
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${rootPath}`,
|
`--allow-fs-read=${rootPath}`,
|
||||||
'--allow-child-process',
|
'--allow-child-process',
|
||||||
'--no-warnings',
|
'--no-warnings',
|
||||||
|
|
|
@ -48,7 +48,7 @@ function spawnProcess(script, bench, state) {
|
||||||
function main({ count, script, nFiles, prefixPath }) {
|
function main({ count, script, nFiles, prefixPath }) {
|
||||||
script = path.resolve(__dirname, '../../', `${script}.js`);
|
script = path.resolve(__dirname, '../../', `${script}.js`);
|
||||||
const optionsWithScript = [
|
const optionsWithScript = [
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${script}`,
|
`--allow-fs-read=${script}`,
|
||||||
...mockFiles(nFiles, prefixPath).map((file) => '--allow-fs-read=' + file),
|
...mockFiles(nFiles, prefixPath).map((file) => '--allow-fs-read=' + file),
|
||||||
script,
|
script,
|
||||||
|
|
|
@ -123,7 +123,7 @@ require('nodejs-addon-example');
|
||||||
```
|
```
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission --allow-fs-read=* index.js
|
$ node --permission --allow-fs-read=* index.js
|
||||||
node:internal/modules/cjs/loader:1319
|
node:internal/modules/cjs/loader:1319
|
||||||
return process.dlopen(module, path.toNamespacedPath(filename));
|
return process.dlopen(module, path.toNamespacedPath(filename));
|
||||||
^
|
^
|
||||||
|
@ -165,7 +165,7 @@ childProcess.spawn('node', ['-e', 'require("fs").writeFileSync("/new-file", "exa
|
||||||
```
|
```
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission --allow-fs-read=* index.js
|
$ node --permission --allow-fs-read=* index.js
|
||||||
node:internal/child_process:388
|
node:internal/child_process:388
|
||||||
const err = this._handle.spawn(options);
|
const err = this._handle.spawn(options);
|
||||||
^
|
^
|
||||||
|
@ -189,12 +189,15 @@ Error: Access to this API has been restricted
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v20.0.0
|
added: v20.0.0
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/56201
|
||||||
|
description: Permission Model and --allow-fs flags are stable.
|
||||||
- version: v20.7.0
|
- version: v20.7.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/49047
|
pr-url: https://github.com/nodejs/node/pull/49047
|
||||||
description: Paths delimited by comma (`,`) are no longer allowed.
|
description: Paths delimited by comma (`,`) are no longer allowed.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
> Stability: 1.1 - Active development
|
> Stability: 2 - Stable.
|
||||||
|
|
||||||
This flag configures file system read permissions using
|
This flag configures file system read permissions using
|
||||||
the [Permission Model][].
|
the [Permission Model][].
|
||||||
|
@ -210,7 +213,7 @@ Examples can be found in the [File System Permissions][] documentation.
|
||||||
The initializer module also needs to be allowed. Consider the following example:
|
The initializer module also needs to be allowed. Consider the following example:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission index.js
|
$ node --permission index.js
|
||||||
|
|
||||||
Error: Access to this API has been restricted
|
Error: Access to this API has been restricted
|
||||||
at node:internal/main/run_main_module:23:47 {
|
at node:internal/main/run_main_module:23:47 {
|
||||||
|
@ -223,7 +226,7 @@ Error: Access to this API has been restricted
|
||||||
The process needs to have access to the `index.js` module:
|
The process needs to have access to the `index.js` module:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
node --experimental-permission --allow-fs-read=/path/to/index.js index.js
|
node --permission --allow-fs-read=/path/to/index.js index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
### `--allow-fs-write`
|
### `--allow-fs-write`
|
||||||
|
@ -231,12 +234,15 @@ node --experimental-permission --allow-fs-read=/path/to/index.js index.js
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v20.0.0
|
added: v20.0.0
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/56201
|
||||||
|
description: Permission Model and --allow-fs flags are stable.
|
||||||
- version: v20.7.0
|
- version: v20.7.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/49047
|
pr-url: https://github.com/nodejs/node/pull/49047
|
||||||
description: Paths delimited by comma (`,`) are no longer allowed.
|
description: Paths delimited by comma (`,`) are no longer allowed.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
> Stability: 1.1 - Active development
|
> Stability: 2 - Stable.
|
||||||
|
|
||||||
This flag configures file system write permissions using
|
This flag configures file system write permissions using
|
||||||
the [Permission Model][].
|
the [Permission Model][].
|
||||||
|
@ -282,7 +288,7 @@ new WASI({
|
||||||
```
|
```
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission --allow-fs-read=* index.js
|
$ node --permission --allow-fs-read=* index.js
|
||||||
|
|
||||||
Error: Access to this API has been restricted
|
Error: Access to this API has been restricted
|
||||||
at node:internal/main/run_main_module:30:49 {
|
at node:internal/main/run_main_module:30:49 {
|
||||||
|
@ -313,7 +319,7 @@ new Worker(__filename);
|
||||||
```
|
```
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission --allow-fs-read=* index.js
|
$ node --permission --allow-fs-read=* index.js
|
||||||
|
|
||||||
Error: Access to this API has been restricted
|
Error: Access to this API has been restricted
|
||||||
at node:internal/main/run_main_module:17:47 {
|
at node:internal/main/run_main_module:17:47 {
|
||||||
|
@ -935,24 +941,6 @@ added:
|
||||||
|
|
||||||
Enable experimental support for the network inspection with Chrome DevTools.
|
Enable experimental support for the network inspection with Chrome DevTools.
|
||||||
|
|
||||||
### `--experimental-permission`
|
|
||||||
|
|
||||||
<!-- YAML
|
|
||||||
added: v20.0.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
> Stability: 1.1 - Active development
|
|
||||||
|
|
||||||
Enable the Permission Model for current process. When enabled, the
|
|
||||||
following permissions are restricted:
|
|
||||||
|
|
||||||
* File System - manageable through
|
|
||||||
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
|
|
||||||
* Child Process - manageable through [`--allow-child-process`][] flag
|
|
||||||
* Worker Threads - manageable through [`--allow-worker`][] flag
|
|
||||||
* WASI - manageable through [`--allow-wasi`][] flag
|
|
||||||
* Addons - manageable through [`--allow-addons`][] flag
|
|
||||||
|
|
||||||
### `--experimental-print-required-tla`
|
### `--experimental-print-required-tla`
|
||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
|
@ -1783,6 +1771,28 @@ unless either the `--pending-deprecation` command-line flag, or the
|
||||||
are used to provide a kind of selective "early warning" mechanism that
|
are used to provide a kind of selective "early warning" mechanism that
|
||||||
developers may leverage to detect deprecated API usage.
|
developers may leverage to detect deprecated API usage.
|
||||||
|
|
||||||
|
### `--permission`
|
||||||
|
|
||||||
|
<!-- YAML
|
||||||
|
added: v20.0.0
|
||||||
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/56201
|
||||||
|
description: Permission Model is now stable.
|
||||||
|
-->
|
||||||
|
|
||||||
|
> Stability: 2 - Stable.
|
||||||
|
|
||||||
|
Enable the Permission Model for current process. When enabled, the
|
||||||
|
following permissions are restricted:
|
||||||
|
|
||||||
|
* File System - manageable through
|
||||||
|
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
|
||||||
|
* Child Process - manageable through [`--allow-child-process`][] flag
|
||||||
|
* Worker Threads - manageable through [`--allow-worker`][] flag
|
||||||
|
* WASI - manageable through [`--allow-wasi`][] flag
|
||||||
|
* Addons - manageable through [`--allow-addons`][] flag
|
||||||
|
|
||||||
### `--preserve-symlinks`
|
### `--preserve-symlinks`
|
||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
|
@ -3092,6 +3102,7 @@ one is included in the list below.
|
||||||
* `--openssl-legacy-provider`
|
* `--openssl-legacy-provider`
|
||||||
* `--openssl-shared-config`
|
* `--openssl-shared-config`
|
||||||
* `--pending-deprecation`
|
* `--pending-deprecation`
|
||||||
|
* `--permission`
|
||||||
* `--preserve-symlinks-main`
|
* `--preserve-symlinks-main`
|
||||||
* `--preserve-symlinks`
|
* `--preserve-symlinks`
|
||||||
* `--prof-process`
|
* `--prof-process`
|
||||||
|
|
|
@ -28,25 +28,25 @@ If you find a potential security vulnerability, please refer to our
|
||||||
|
|
||||||
<!-- type=misc -->
|
<!-- type=misc -->
|
||||||
|
|
||||||
> Stability: 1.1 - Active development
|
> Stability: 2 - Stable.
|
||||||
|
|
||||||
<!-- name=permission-model -->
|
<!-- name=permission-model -->
|
||||||
|
|
||||||
The Node.js Permission Model is a mechanism for restricting access to specific
|
The Node.js Permission Model is a mechanism for restricting access to specific
|
||||||
resources during execution.
|
resources during execution.
|
||||||
The API exists behind a flag [`--experimental-permission`][] which when enabled,
|
The API exists behind a flag [`--permission`][] which when enabled,
|
||||||
will restrict access to all available permissions.
|
will restrict access to all available permissions.
|
||||||
|
|
||||||
The available permissions are documented by the [`--experimental-permission`][]
|
The available permissions are documented by the [`--permission`][]
|
||||||
flag.
|
flag.
|
||||||
|
|
||||||
When starting Node.js with `--experimental-permission`,
|
When starting Node.js with `--permission`,
|
||||||
the ability to access the file system through the `fs` module, spawn processes,
|
the ability to access the file system through the `fs` module, spawn processes,
|
||||||
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
|
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
|
||||||
will be restricted.
|
will be restricted.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission index.js
|
$ node --permission index.js
|
||||||
|
|
||||||
Error: Access to this API has been restricted
|
Error: Access to this API has been restricted
|
||||||
at node:internal/main/run_main_module:23:47 {
|
at node:internal/main/run_main_module:23:47 {
|
||||||
|
@ -64,7 +64,7 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
|
||||||
|
|
||||||
#### Runtime API
|
#### Runtime API
|
||||||
|
|
||||||
When enabling the Permission Model through the [`--experimental-permission`][]
|
When enabling the Permission Model through the [`--permission`][]
|
||||||
flag a new property `permission` is added to the `process` object.
|
flag a new property `permission` is added to the `process` object.
|
||||||
This property contains one function:
|
This property contains one function:
|
||||||
|
|
||||||
|
@ -90,10 +90,8 @@ To allow access to the file system, use the [`--allow-fs-read`][] and
|
||||||
[`--allow-fs-write`][] flags:
|
[`--allow-fs-write`][] flags:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ node --experimental-permission --allow-fs-read=* --allow-fs-write=* index.js
|
$ node --permission --allow-fs-read=* --allow-fs-write=* index.js
|
||||||
Hello world!
|
Hello world!
|
||||||
(node:19836) ExperimentalWarning: Permission is an experimental feature
|
|
||||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The valid arguments for both flags are:
|
The valid arguments for both flags are:
|
||||||
|
@ -167,5 +165,5 @@ There are constraints you need to know before using this system:
|
||||||
[`--allow-fs-write`]: cli.md#--allow-fs-write
|
[`--allow-fs-write`]: cli.md#--allow-fs-write
|
||||||
[`--allow-wasi`]: cli.md#--allow-wasi
|
[`--allow-wasi`]: cli.md#--allow-wasi
|
||||||
[`--allow-worker`]: cli.md#--allow-worker
|
[`--allow-worker`]: cli.md#--allow-worker
|
||||||
[`--experimental-permission`]: cli.md#--experimental-permission
|
[`--permission`]: cli.md#--permission
|
||||||
[`permission.has()`]: process.md#processpermissionhasscope-reference
|
[`permission.has()`]: process.md#processpermissionhasscope-reference
|
||||||
|
|
|
@ -3107,7 +3107,7 @@ added: v20.0.0
|
||||||
|
|
||||||
* {Object}
|
* {Object}
|
||||||
|
|
||||||
This API is available through the [`--experimental-permission`][] flag.
|
This API is available through the [`--permission`][] flag.
|
||||||
|
|
||||||
`process.permission` is an object whose methods are used to manage permissions
|
`process.permission` is an object whose methods are used to manage permissions
|
||||||
for the current process. Additional documentation is available in the
|
for the current process. Additional documentation is available in the
|
||||||
|
@ -4444,8 +4444,8 @@ cases:
|
||||||
[`'exit'`]: #event-exit
|
[`'exit'`]: #event-exit
|
||||||
[`'message'`]: child_process.md#event-message
|
[`'message'`]: child_process.md#event-message
|
||||||
[`'uncaughtException'`]: #event-uncaughtexception
|
[`'uncaughtException'`]: #event-uncaughtexception
|
||||||
[`--experimental-permission`]: cli.md#--experimental-permission
|
|
||||||
[`--no-deprecation`]: cli.md#--no-deprecation
|
[`--no-deprecation`]: cli.md#--no-deprecation
|
||||||
|
[`--permission`]: cli.md#--permission
|
||||||
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
|
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
|
||||||
[`Buffer`]: buffer.md
|
[`Buffer`]: buffer.md
|
||||||
[`ChildProcess.disconnect()`]: child_process.md#subprocessdisconnect
|
[`ChildProcess.disconnect()`]: child_process.md#subprocessdisconnect
|
||||||
|
|
|
@ -171,8 +171,8 @@ Specify the
|
||||||
.Ar module
|
.Ar module
|
||||||
to use as a custom module loader.
|
to use as a custom module loader.
|
||||||
.
|
.
|
||||||
.It Fl -experimental-permission
|
.It Fl -permission
|
||||||
Enable the experimental permission model.
|
Enable the permission model.
|
||||||
.
|
.
|
||||||
.It Fl -experimental-shadow-realm
|
.It Fl -experimental-shadow-realm
|
||||||
Use this flag to enable ShadowRealm support.
|
Use this flag to enable ShadowRealm support.
|
||||||
|
|
|
@ -9,16 +9,16 @@ const { validateString, validateBuffer } = require('internal/validators');
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const { isBuffer } = Buffer;
|
const { isBuffer } = Buffer;
|
||||||
|
|
||||||
let experimentalPermission;
|
let _permission;
|
||||||
|
|
||||||
module.exports = ObjectFreeze({
|
module.exports = ObjectFreeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
if (experimentalPermission === undefined) {
|
if (_permission === undefined) {
|
||||||
const { getOptionValue } = require('internal/options');
|
const { getOptionValue } = require('internal/options');
|
||||||
experimentalPermission = getOptionValue('--experimental-permission');
|
_permission = getOptionValue('--permission');
|
||||||
}
|
}
|
||||||
return experimentalPermission;
|
return _permission;
|
||||||
},
|
},
|
||||||
has(scope, reference) {
|
has(scope, reference) {
|
||||||
validateString(scope, 'scope');
|
validateString(scope, 'scope');
|
||||||
|
|
|
@ -520,14 +520,13 @@ function initializeClusterIPC() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializePermission() {
|
function initializePermission() {
|
||||||
const experimentalPermission = getOptionValue('--experimental-permission');
|
const permission = getOptionValue('--permission');
|
||||||
if (experimentalPermission) {
|
if (permission) {
|
||||||
process.binding = function binding(_module) {
|
process.binding = function binding(_module) {
|
||||||
throw new ERR_ACCESS_DENIED('process.binding');
|
throw new ERR_ACCESS_DENIED('process.binding');
|
||||||
};
|
};
|
||||||
// Guarantee path module isn't monkey-patched to bypass permission model
|
// Guarantee path module isn't monkey-patched to bypass permission model
|
||||||
ObjectFreeze(require('path'));
|
ObjectFreeze(require('path'));
|
||||||
emitExperimentalWarning('Permission');
|
|
||||||
const { has } = require('internal/process/permission');
|
const { has } = require('internal/process/permission');
|
||||||
const warnFlags = [
|
const warnFlags = [
|
||||||
'--allow-addons',
|
'--allow-addons',
|
||||||
|
@ -579,7 +578,7 @@ function initializePermission() {
|
||||||
ArrayPrototypeForEach(availablePermissionFlags, (flag) => {
|
ArrayPrototypeForEach(availablePermissionFlags, (flag) => {
|
||||||
const value = getOptionValue(flag);
|
const value = getOptionValue(flag);
|
||||||
if (value.length) {
|
if (value.length) {
|
||||||
throw new ERR_MISSING_OPTION('--experimental-permission');
|
throw new ERR_MISSING_OPTION('--permission');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -920,7 +920,7 @@ Environment::Environment(IsolateData* isolate_data,
|
||||||
std::move(traced_value));
|
std::move(traced_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_->experimental_permission) {
|
if (options_->permission) {
|
||||||
permission()->EnablePermissions();
|
permission()->EnablePermissions();
|
||||||
// The process shouldn't be able to neither
|
// The process shouldn't be able to neither
|
||||||
// spawn/worker nor use addons or enable inspector
|
// spawn/worker nor use addons or enable inspector
|
||||||
|
|
|
@ -456,11 +456,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
|
||||||
"experimental ES Module import.meta.resolve() parentURL support",
|
"experimental ES Module import.meta.resolve() parentURL support",
|
||||||
&EnvironmentOptions::experimental_import_meta_resolve,
|
&EnvironmentOptions::experimental_import_meta_resolve,
|
||||||
kAllowedInEnvvar);
|
kAllowedInEnvvar);
|
||||||
AddOption("--experimental-permission",
|
AddOption("--permission",
|
||||||
"enable the permission system",
|
"enable the permission system",
|
||||||
&EnvironmentOptions::experimental_permission,
|
&EnvironmentOptions::permission,
|
||||||
kAllowedInEnvvar,
|
kAllowedInEnvvar,
|
||||||
false);
|
false);
|
||||||
|
AddAlias("--experimental-permission", "--permission");
|
||||||
AddOption("--allow-fs-read",
|
AddOption("--allow-fs-read",
|
||||||
"allow permissions to read the filesystem",
|
"allow permissions to read the filesystem",
|
||||||
&EnvironmentOptions::allow_fs_read,
|
&EnvironmentOptions::allow_fs_read,
|
||||||
|
|
|
@ -132,7 +132,7 @@ class EnvironmentOptions : public Options {
|
||||||
bool experimental_import_meta_resolve = false;
|
bool experimental_import_meta_resolve = false;
|
||||||
std::string input_type; // Value of --input-type
|
std::string input_type; // Value of --input-type
|
||||||
bool entry_is_url = false;
|
bool entry_is_url = false;
|
||||||
bool experimental_permission = false;
|
bool permission = false;
|
||||||
std::vector<std::string> allow_fs_read;
|
std::vector<std::string> allow_fs_read;
|
||||||
std::vector<std::string> allow_fs_write;
|
std::vector<std::string> allow_fs_write;
|
||||||
bool allow_addons = false;
|
bool allow_addons = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Flags: --expose-internals --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --expose-internals --permission --allow-fs-read=* --allow-child-process
|
||||||
|
|
||||||
require('../common');
|
require('../common');
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ describe('legacyMainResolve', () => {
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--expose-internals',
|
'--expose-internals',
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
...allowReadFiles,
|
...allowReadFiles,
|
||||||
'-e',
|
'-e',
|
||||||
`
|
`
|
||||||
|
@ -98,7 +98,7 @@ describe('legacyMainResolve', () => {
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--expose-internals',
|
'--expose-internals',
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
...allowReadFiles,
|
...allowReadFiles,
|
||||||
'-e',
|
'-e',
|
||||||
`
|
`
|
||||||
|
|
|
@ -182,7 +182,7 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
||||||
it('should work without worker permission', async () => {
|
it('should work without worker permission', async () => {
|
||||||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
||||||
'--no-warnings',
|
'--no-warnings',
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read',
|
'--allow-fs-read',
|
||||||
'*',
|
'*',
|
||||||
'--experimental-loader',
|
'--experimental-loader',
|
||||||
|
@ -199,7 +199,7 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
||||||
it('should allow loader hooks to spawn workers when allowed by the CLI flags', async () => {
|
it('should allow loader hooks to spawn workers when allowed by the CLI flags', async () => {
|
||||||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
||||||
'--no-warnings',
|
'--no-warnings',
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-worker',
|
'--allow-worker',
|
||||||
'--allow-fs-read',
|
'--allow-fs-read',
|
||||||
'*',
|
'*',
|
||||||
|
@ -217,7 +217,7 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
||||||
it('should not allow loader hooks to spawn workers if restricted by the CLI flags', async () => {
|
it('should not allow loader hooks to spawn workers if restricted by the CLI flags', async () => {
|
||||||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [
|
||||||
'--no-warnings',
|
'--no-warnings',
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read',
|
'--allow-fs-read',
|
||||||
'*',
|
'*',
|
||||||
'--experimental-loader',
|
'--experimental-loader',
|
||||||
|
|
2
test/fixtures/dotenv/node-options.env
vendored
2
test/fixtures/dotenv/node-options.env
vendored
|
@ -1,6 +1,6 @@
|
||||||
CUSTOM_VARIABLE=hello-world
|
CUSTOM_VARIABLE=hello-world
|
||||||
NODE_NO_WARNINGS=1
|
NODE_NO_WARNINGS=1
|
||||||
NODE_OPTIONS="--experimental-permission --allow-fs-read=*"
|
NODE_OPTIONS="--permission --allow-fs-read=*"
|
||||||
TZ=Pacific/Honolulu
|
TZ=Pacific/Honolulu
|
||||||
UV_THREADPOOL_SIZE=5
|
UV_THREADPOOL_SIZE=5
|
||||||
BASIC=overridden
|
BASIC=overridden
|
||||||
|
|
|
@ -14,8 +14,8 @@ if (process.features.inspector) {
|
||||||
}
|
}
|
||||||
requiresArgument('--eval');
|
requiresArgument('--eval');
|
||||||
|
|
||||||
missingOption('--allow-fs-read=*', '--experimental-permission');
|
missingOption('--allow-fs-read=*', '--permission');
|
||||||
missingOption('--allow-fs-write=*', '--experimental-permission');
|
missingOption('--allow-fs-write=*', '--permission');
|
||||||
|
|
||||||
function missingOption(option, requiredOption) {
|
function missingOption(option, requiredOption) {
|
||||||
const r = spawnSync(process.execPath, [option], { encoding: 'utf8' });
|
const r = spawnSync(process.execPath, [option], { encoding: 'utf8' });
|
||||||
|
|
|
@ -12,7 +12,7 @@ const path = require('path');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission', '-e',
|
'--permission', '-e',
|
||||||
`console.log(process.permission.has("fs"));
|
`console.log(process.permission.has("fs"));
|
||||||
console.log(process.permission.has("fs.read"));
|
console.log(process.permission.has("fs.read"));
|
||||||
console.log(process.permission.has("fs.write"));`,
|
console.log(process.permission.has("fs.write"));`,
|
||||||
|
@ -31,7 +31,7 @@ const path = require('path');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-write', tmpPath, '-e',
|
'--allow-fs-write', tmpPath, '-e',
|
||||||
`console.log(process.permission.has("fs"));
|
`console.log(process.permission.has("fs"));
|
||||||
console.log(process.permission.has("fs.read"));
|
console.log(process.permission.has("fs.read"));
|
||||||
|
@ -51,7 +51,7 @@ const path = require('path');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-write', '*', '-e',
|
'--allow-fs-write', '*', '-e',
|
||||||
`console.log(process.permission.has("fs"));
|
`console.log(process.permission.has("fs"));
|
||||||
console.log(process.permission.has("fs.read"));
|
console.log(process.permission.has("fs.read"));
|
||||||
|
@ -70,7 +70,7 @@ const path = require('path');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', '*', '-e',
|
'--allow-fs-read', '*', '-e',
|
||||||
`console.log(process.permission.has("fs"));
|
`console.log(process.permission.has("fs"));
|
||||||
console.log(process.permission.has("fs.read"));
|
console.log(process.permission.has("fs.read"));
|
||||||
|
@ -89,7 +89,7 @@ const path = require('path');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-write=*', '-p',
|
'--allow-fs-write=*', '-p',
|
||||||
'fs.readFileSync(process.execPath)',
|
'fs.readFileSync(process.execPath)',
|
||||||
]
|
]
|
||||||
|
@ -104,7 +104,7 @@ const path = require('path');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'-p',
|
'-p',
|
||||||
'fs.readFileSync(process.execPath)',
|
'fs.readFileSync(process.execPath)',
|
||||||
]
|
]
|
||||||
|
@ -119,7 +119,7 @@ const path = require('path');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read=*', '-p',
|
'--allow-fs-read=*', '-p',
|
||||||
'fs.writeFileSync("policy-deny-example.md", "# test")',
|
'fs.writeFileSync("policy-deny-example.md", "# test")',
|
||||||
]
|
]
|
||||||
|
@ -145,7 +145,7 @@ const path = require('path');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${firstPath}`,
|
`--allow-fs-read=${firstPath}`,
|
||||||
file,
|
file,
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,7 +12,7 @@ const path = require('path');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-write', tmpPath, '--allow-fs-write', otherPath, '-e',
|
'--allow-fs-write', tmpPath, '--allow-fs-write', otherPath, '-e',
|
||||||
`console.log(process.permission.has("fs"));
|
`console.log(process.permission.has("fs"));
|
||||||
console.log(process.permission.has("fs.read"));
|
console.log(process.permission.has("fs.read"));
|
||||||
|
@ -36,7 +36,7 @@ const path = require('path');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-write',
|
'--allow-fs-write',
|
||||||
tmpPath,
|
tmpPath,
|
||||||
'--allow-fs-write',
|
'--allow-fs-write',
|
||||||
|
@ -63,7 +63,7 @@ const path = require('path');
|
||||||
const { status, stdout, stderr } = spawnSync(
|
const { status, stdout, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read=*',
|
'--allow-fs-read=*',
|
||||||
`--allow-fs-write=${filePath}`,
|
`--allow-fs-write=${filePath}`,
|
||||||
'-e',
|
'-e',
|
||||||
|
|
|
@ -26,7 +26,7 @@ const fs = require('fs');
|
||||||
spawnSyncAndAssert(
|
spawnSyncAndAssert(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission', `--allow-fs-read=${scriptDir}`, `--allow-fs-write=${scriptDir}`,
|
'--permission', `--allow-fs-read=${scriptDir}`, `--allow-fs-write=${scriptDir}`,
|
||||||
'-r', wrapper, empty,
|
'-r', wrapper, empty,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ function testAllowed(readDir, writeDir, envDir) {
|
||||||
spawnSyncAndAssert(
|
spawnSyncAndAssert(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${dummyDir}`,
|
`--allow-fs-read=${dummyDir}`,
|
||||||
`--allow-fs-read=${readDir}`,
|
`--allow-fs-read=${readDir}`,
|
||||||
`--allow-fs-write=${writeDir}`,
|
`--allow-fs-write=${writeDir}`,
|
||||||
|
@ -47,7 +47,7 @@ function testAllowed(readDir, writeDir, envDir) {
|
||||||
spawnSyncAndAssert(
|
spawnSyncAndAssert(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${dummyDir}`,
|
`--allow-fs-read=${dummyDir}`,
|
||||||
`--allow-fs-read=${readDir}`,
|
`--allow-fs-read=${readDir}`,
|
||||||
`--allow-fs-write=${writeDir}`,
|
`--allow-fs-write=${writeDir}`,
|
||||||
|
|
|
@ -24,7 +24,7 @@ function testDisallowed(dummyDir, cacheDirInPermission, cacheDirInEnv) {
|
||||||
spawnSyncAndAssert(
|
spawnSyncAndAssert(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${dummyDir}`, // No read or write permission for cache dir.
|
`--allow-fs-read=${dummyDir}`, // No read or write permission for cache dir.
|
||||||
`--allow-fs-write=${dummyDir}`,
|
`--allow-fs-write=${dummyDir}`,
|
||||||
script,
|
script,
|
||||||
|
@ -47,7 +47,7 @@ function testDisallowed(dummyDir, cacheDirInPermission, cacheDirInEnv) {
|
||||||
spawnSyncAndAssert(
|
spawnSyncAndAssert(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${dummyDir}`,
|
`--allow-fs-read=${dummyDir}`,
|
||||||
`--allow-fs-read=${cacheDirInPermission}`, // Read-only
|
`--allow-fs-read=${cacheDirInPermission}`, // Read-only
|
||||||
`--allow-fs-write=${dummyDir}`,
|
`--allow-fs-write=${dummyDir}`,
|
||||||
|
@ -71,7 +71,7 @@ function testDisallowed(dummyDir, cacheDirInPermission, cacheDirInEnv) {
|
||||||
spawnSyncAndAssert(
|
spawnSyncAndAssert(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${dummyDir}`,
|
`--allow-fs-read=${dummyDir}`,
|
||||||
`--allow-fs-write=${cacheDirInPermission}`, // Write-only
|
`--allow-fs-write=${cacheDirInPermission}`, // Write-only
|
||||||
script,
|
script,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-addons --allow-fs-read=*
|
// Flags: --permission --allow-addons --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-child-process --allow-fs-read=*
|
// Flags: --permission --allow-child-process --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-wasi --allow-fs-read=*
|
// Flags: --permission --allow-wasi --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-worker --allow-fs-read=*
|
// Flags: --permission --allow-worker --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('../common');
|
require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const common = require('../common');
|
|
||||||
common.skipIfWorker();
|
|
||||||
const assert = require('assert');
|
|
||||||
|
|
||||||
// This test ensures that the experimental message is emitted
|
|
||||||
// when using permission system
|
|
||||||
|
|
||||||
process.on('warning', common.mustCall((warning) => {
|
|
||||||
assert.match(warning.message, /Permission is an experimental feature/);
|
|
||||||
}, 1));
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -13,7 +13,7 @@ const { spawnSync } = require('child_process');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', '*',
|
'--allow-fs-read', '*',
|
||||||
'--allow-fs-write', path.resolve('../fixtures/permission/deny/regular-file.md'),
|
'--allow-fs-write', path.resolve('../fixtures/permission/deny/regular-file.md'),
|
||||||
'-e',
|
'-e',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --expose-internals --experimental-permission --allow-fs-read=test/common* --allow-fs-read=tools* --allow-fs-read=test/parallel* --allow-child-process
|
// Flags: --expose-internals --permission --allow-fs-read=test/common* --allow-fs-read=tools* --allow-fs-read=test/parallel* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -28,7 +28,7 @@ const commonPath = path.join(__filename, '../../common');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission', `--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, file,
|
'--permission', `--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, file,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
env: {
|
env: {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -12,7 +12,7 @@ const { spawnSync } = require('child_process');
|
||||||
const { status, stdout } = spawnSync(
|
const { status, stdout } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', '*',
|
'--allow-fs-read', '*',
|
||||||
'--allow-fs-write', '../fixtures/permission/deny/regular-file.md',
|
'--allow-fs-write', '../fixtures/permission/deny/regular-file.md',
|
||||||
'-e',
|
'-e',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -14,7 +14,7 @@ const { spawnSync } = require('node:child_process');
|
||||||
const { status, stdout, stderr } = spawnSync(
|
const { status, stdout, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', mainModule,
|
'--allow-fs-read', mainModule,
|
||||||
'--allow-fs-read', requiredModule,
|
'--allow-fs-read', requiredModule,
|
||||||
mainModule,
|
mainModule,
|
||||||
|
@ -31,7 +31,7 @@ const { spawnSync } = require('node:child_process');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', mainModule,
|
'--allow-fs-read', mainModule,
|
||||||
mainModule,
|
mainModule,
|
||||||
]
|
]
|
||||||
|
@ -48,7 +48,7 @@ const { spawnSync } = require('node:child_process');
|
||||||
const { status, stdout, stderr } = spawnSync(
|
const { status, stdout, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', mainModule,
|
'--allow-fs-read', mainModule,
|
||||||
'--allow-fs-read', requiredModule,
|
'--allow-fs-read', requiredModule,
|
||||||
mainModule,
|
mainModule,
|
||||||
|
@ -65,7 +65,7 @@ const { spawnSync } = require('node:child_process');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read', mainModule,
|
'--allow-fs-read', mainModule,
|
||||||
mainModule,
|
mainModule,
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-fs-write=*
|
// Flags: --permission --allow-fs-read=* --allow-fs-write=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -35,7 +35,7 @@ fs.writeFileSync(path.join(readWriteFolder, 'file'), 'NO evil file contents');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, `--allow-fs-read=${readOnlyFolder}`, `--allow-fs-read=${readWriteFolder}`,
|
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, `--allow-fs-read=${readOnlyFolder}`, `--allow-fs-read=${readWriteFolder}`,
|
||||||
`--allow-fs-write=${readWriteFolder}`, `--allow-fs-write=${writeOnlyFolder}`,
|
`--allow-fs-write=${readWriteFolder}`, `--allow-fs-write=${writeOnlyFolder}`,
|
||||||
file,
|
file,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -36,7 +36,7 @@ const symlinkFromBlockedFile = tmpdir.resolve('example-symlink.md');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, `--allow-fs-read=${symlinkFromBlockedFile}`,
|
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, `--allow-fs-read=${symlinkFromBlockedFile}`,
|
||||||
`--allow-fs-write=${symlinkFromBlockedFile}`,
|
`--allow-fs-write=${symlinkFromBlockedFile}`,
|
||||||
file,
|
file,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -30,7 +30,7 @@ const commonPathWildcard = path.join(__filename, '../../common*');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, `--allow-fs-read=${allowedFolder}`,
|
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, `--allow-fs-read=${allowedFolder}`,
|
||||||
`--allow-fs-write=${allowedFolder}`,
|
`--allow-fs-write=${allowedFolder}`,
|
||||||
file,
|
file,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -31,7 +31,7 @@ if (common.isWindows) {
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
...allowList.flatMap((path) => ['--allow-fs-read', path]),
|
...allowList.flatMap((path) => ['--allow-fs-read', path]),
|
||||||
'-e',
|
'-e',
|
||||||
`
|
`
|
||||||
|
@ -66,7 +66,7 @@ if (common.isWindows) {
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
...allowList.flatMap((path) => ['--allow-fs-read', path]),
|
...allowList.flatMap((path) => ['--allow-fs-read', path]),
|
||||||
'-e',
|
'-e',
|
||||||
`
|
`
|
||||||
|
@ -91,7 +91,7 @@ if (common.isWindows) {
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, ...allowList.flatMap((path) => ['--allow-fs-read', path]),
|
`--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, ...allowList.flatMap((path) => ['--allow-fs-read', path]),
|
||||||
file,
|
file,
|
||||||
],
|
],
|
||||||
|
@ -104,7 +104,7 @@ if (common.isWindows) {
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read=/a/b/*',
|
'--allow-fs-read=/a/b/*',
|
||||||
'--allow-fs-read=/a/b/d',
|
'--allow-fs-read=/a/b/d',
|
||||||
'--allow-fs-read=/etc/passwd.*',
|
'--allow-fs-read=/etc/passwd.*',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -13,7 +13,7 @@ if (!common.isWindows) {
|
||||||
|
|
||||||
{
|
{
|
||||||
const { stdout, status } = spawnSync(process.execPath, [
|
const { stdout, status } = spawnSync(process.execPath, [
|
||||||
'--experimental-permission', '--allow-fs-write', 'C:\\\\', '-e',
|
'--permission', '--allow-fs-write', 'C:\\\\', '-e',
|
||||||
'console.log(process.permission.has("fs.write", "C:\\\\"))',
|
'console.log(process.permission.has("fs.write", "C:\\\\"))',
|
||||||
]);
|
]);
|
||||||
assert.strictEqual(stdout.toString(), 'true\n');
|
assert.strictEqual(stdout.toString(), 'true\n');
|
||||||
|
@ -22,7 +22,7 @@ if (!common.isWindows) {
|
||||||
|
|
||||||
{
|
{
|
||||||
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
||||||
'--experimental-permission', '--allow-fs-write="\\\\?\\C:\\"', '-e',
|
'--permission', '--allow-fs-write="\\\\?\\C:\\"', '-e',
|
||||||
'console.log(process.permission.has("fs.write", "C:\\\\"))',
|
'console.log(process.permission.has("fs.write", "C:\\\\"))',
|
||||||
]);
|
]);
|
||||||
assert.strictEqual(stdout.toString(), 'false\n', stderr.toString());
|
assert.strictEqual(stdout.toString(), 'false\n', stderr.toString());
|
||||||
|
@ -31,7 +31,7 @@ if (!common.isWindows) {
|
||||||
|
|
||||||
{
|
{
|
||||||
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
||||||
'--experimental-permission', '--allow-fs-write', 'C:\\', '-e',
|
'--permission', '--allow-fs-write', 'C:\\', '-e',
|
||||||
`const path = require('path');
|
`const path = require('path');
|
||||||
console.log(process.permission.has('fs.write', path.toNamespacedPath('C:\\\\')))`,
|
console.log(process.permission.has('fs.write', path.toNamespacedPath('C:\\\\')))`,
|
||||||
]);
|
]);
|
||||||
|
@ -41,7 +41,7 @@ if (!common.isWindows) {
|
||||||
|
|
||||||
{
|
{
|
||||||
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
const { stdout, status, stderr } = spawnSync(process.execPath, [
|
||||||
'--experimental-permission', '--allow-fs-write', 'C:\\*', '-e',
|
'--permission', '--allow-fs-write', 'C:\\*', '-e',
|
||||||
"console.log(process.permission.has('fs.write', '\\\\\\\\A\\\\C:\\Users'))",
|
"console.log(process.permission.has('fs.write', '\\\\\\\\A\\\\C:\\Users'))",
|
||||||
]);
|
]);
|
||||||
assert.strictEqual(stdout.toString(), 'false\n', stderr.toString());
|
assert.strictEqual(stdout.toString(), 'false\n', stderr.toString());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -24,7 +24,7 @@ const file = fixtures.path('permission', 'fs-write.js');
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read=*',
|
'--allow-fs-read=*',
|
||||||
`--allow-fs-write=${regularFile}`, `--allow-fs-write=${commonPath}`,
|
`--allow-fs-write=${regularFile}`, `--allow-fs-write=${commonPath}`,
|
||||||
file,
|
file,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -14,7 +14,7 @@ common.skipIfInspectorDisabled();
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--allow-fs-read=*',
|
'--allow-fs-read=*',
|
||||||
'--inspect-brk',
|
'--inspect-brk',
|
||||||
file,
|
file,
|
||||||
|
@ -29,7 +29,7 @@ common.skipIfInspectorDisabled();
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'--inspect-brk',
|
'--inspect-brk',
|
||||||
'--eval',
|
'--eval',
|
||||||
'console.log("Hi!")',
|
'console.log("Hi!")',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
// Flags: --permission --allow-fs-read=* --allow-child-process
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
@ -26,7 +26,7 @@ if (!common.hasCrypto)
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission',
|
'--permission',
|
||||||
'-e',
|
'-e',
|
||||||
'(new (require("inspector")).Session()).connect()',
|
'(new (require("inspector")).Session()).connect()',
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -13,13 +13,13 @@ const fixtures = require('../common/fixtures');
|
||||||
const file = fixtures.path('permission', 'processbinding.js');
|
const file = fixtures.path('permission', 'processbinding.js');
|
||||||
|
|
||||||
// Due to linting rules-utils.js:isBinding check, process.binding() should
|
// Due to linting rules-utils.js:isBinding check, process.binding() should
|
||||||
// not be called when --experimental-permission is enabled.
|
// not be called when --permission is enabled.
|
||||||
// Always spawn a child process
|
// Always spawn a child process
|
||||||
{
|
{
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission', '--allow-fs-read=*', file,
|
'--permission', '--allow-fs-read=*', file,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
assert.strictEqual(status, 0, stderr.toString());
|
assert.strictEqual(status, 0, stderr.toString());
|
||||||
|
|
|
@ -15,7 +15,7 @@ for (const flag of warnFlags) {
|
||||||
const { status, stderr } = spawnSync(
|
const { status, stderr } = spawnSync(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[
|
[
|
||||||
'--experimental-permission', flag, '-e',
|
'--permission', flag, '-e',
|
||||||
'setTimeout(() => {}, 1)',
|
'setTimeout(() => {}, 1)',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Flags: --experimental-permission --allow-fs-read=*
|
// Flags: --permission --allow-fs-read=*
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
|
@ -78,7 +78,7 @@ describe('process.loadEnvFile()', () => {
|
||||||
`.trim();
|
`.trim();
|
||||||
const child = await common.spawnPromisified(
|
const child = await common.spawnPromisified(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[ '--eval', code, '--experimental-permission' ],
|
[ '--eval', code, '--permission' ],
|
||||||
{ cwd: __dirname },
|
{ cwd: __dirname },
|
||||||
);
|
);
|
||||||
assert.match(child.stderr, /Error: Access to this API has been restricted/);
|
assert.match(child.stderr, /Error: Access to this API has been restricted/);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Flags: --expose-internals --experimental-permission --allow-fs-read=*
|
// Flags: --expose-internals --permission --allow-fs-read=*
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
|
|
|
@ -7,7 +7,7 @@ if (typeof require === 'undefined') {
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { Worker } = require('worker_threads');
|
const { Worker } = require('worker_threads');
|
||||||
|
|
||||||
// When --experimental-permission is enabled, the process
|
// When --permission is enabled, the process
|
||||||
// aren't able to spawn any worker unless --allow-worker is passed.
|
// aren't able to spawn any worker unless --allow-worker is passed.
|
||||||
// Therefore, we skip the permission tests for custom-suites-freestyle
|
// Therefore, we skip the permission tests for custom-suites-freestyle
|
||||||
if (process.permission && !process.permission.has('worker')) {
|
if (process.permission && !process.permission.has('worker')) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue