| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b2a6ee commit efcc5d9
53 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ const bench = common.createBenchmark(main, { | |||
| 17 | 17 | concurrent: [1, 10], | |
| 18 | 18 | }, { | |
| 19 | 19 | flags: [ | |
| 20 | - '--experimental-permission', | ||
| 20 | + '--permission', | ||
| 21 | 21 | '--allow-fs-read=*', | |
| 22 | 22 | '--allow-fs-write=*', | |
| 23 | 23 | '--allow-child-process', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ const rootPath = path.resolve(__dirname, '../../..'); | |||
| 11 | 11 | ||
| 12 | 12 | const options = { | |
| 13 | 13 | flags: [ | |
| 14 | - '--experimental-permission', | ||
| 14 | + '--permission', | ||
| 15 | 15 | `--allow-fs-read=${rootPath}`, | |
| 16 | 16 | '--allow-child-process', | |
| 17 | 17 | '--no-warnings', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ function spawnProcess(script, bench, state) { | |||
| 48 | 48 | function main({ count, script, nFiles, prefixPath }) { | |
| 49 | 49 | script = path.resolve(__dirname, '../../', `${script}.js`); | |
| 50 | 50 | const optionsWithScript = [ | |
| 51 | - '--experimental-permission', | ||
| 51 | + '--permission', | ||
| 52 | 52 | `--allow-fs-read=${script}`, | |
| 53 | 53 | ...mockFiles(nFiles, prefixPath).map((file) => '--allow-fs-read=' + file), | |
| 54 | 54 | script, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,7 +123,7 @@ require('nodejs-addon-example'); | |||
| 123 | 123 | ``` | |
| 124 | 124 | ||
| 125 | 125 | ```console | |
| 126 | - $ node --experimental-permission --allow-fs-read=* index.js | ||
| 126 | + $ node --permission --allow-fs-read=* index.js | ||
| 127 | 127 | node:internal/modules/cjs/loader:1319 | |
| 128 | 128 | return process.dlopen(module, path.toNamespacedPath(filename)); | |
| 129 | 129 | ^ | |
@@ -165,7 +165,7 @@ childProcess.spawn('node', ['-e', 'require("fs").writeFileSync("/new-file", "exa | |||
| 165 | 165 | ``` | |
| 166 | 166 | ||
| 167 | 167 | ```console | |
| 168 | - $ node --experimental-permission --allow-fs-read=* index.js | ||
| 168 | + $ node --permission --allow-fs-read=* index.js | ||
| 169 | 169 | node:internal/child_process:388 | |
| 170 | 170 | const err = this._handle.spawn(options); | |
| 171 | 171 | ^ | |
@@ -189,12 +189,15 @@ Error: Access to this API has been restricted | |||
| 189 | 189 | <!-- YAML | |
| 190 | 190 | added: v20.0.0 | |
| 191 | 191 | changes: | |
| 192 | + - version: REPLACEME | ||
| 193 | + pr-url: https://github.com/nodejs/node/pull/56201 | ||
| 194 | + description: Permission Model and --allow-fs flags are stable. | ||
| 192 | 195 | - version: v20.7.0 | |
| 193 | 196 | pr-url: https://github.com/nodejs/node/pull/49047 | |
| 194 | 197 | description: Paths delimited by comma (`,`) are no longer allowed. | |
| 195 | 198 | --> | |
| 196 | 199 | ||
| 197 | - > Stability: 1.1 - Active development | ||
| 200 | + > Stability: 2 - Stable. | ||
| 198 | 201 | ||
| 199 | 202 | This flag configures file system read permissions using | |
| 200 | 203 | the [Permission Model][]. | |
@@ -210,7 +213,7 @@ Examples can be found in the [File System Permissions][] documentation. | |||
| 210 | 213 | The initializer module also needs to be allowed. Consider the following example: | |
| 211 | 214 | ||
| 212 | 215 | ```console | |
| 213 | - $ node --experimental-permission index.js | ||
| 216 | + $ node --permission index.js | ||
| 214 | 217 | ||
| 215 | 218 | Error: Access to this API has been restricted | |
| 216 | 219 | at node:internal/main/run_main_module:23:47 { | |
@@ -223,20 +226,23 @@ Error: Access to this API has been restricted | |||
| 223 | 226 | The process needs to have access to the `index.js` module: | |
| 224 | 227 | ||
| 225 | 228 | ```bash | |
| 226 | - node --experimental-permission --allow-fs-read=/path/to/index.js index.js | ||
| 229 | + node --permission --allow-fs-read=/path/to/index.js index.js | ||
| 227 | 230 | ``` | |
| 228 | 231 | ||
| 229 | 232 | ### `--allow-fs-write` | |
| 230 | 233 | ||
| 231 | 234 | <!-- YAML | |
| 232 | 235 | added: v20.0.0 | |
| 233 | 236 | changes: | |
| 237 | + - version: REPLACEME | ||
| 238 | + pr-url: https://github.com/nodejs/node/pull/56201 | ||
| 239 | + description: Permission Model and --allow-fs flags are stable. | ||
| 234 | 240 | - version: v20.7.0 | |
| 235 | 241 | pr-url: https://github.com/nodejs/node/pull/49047 | |
| 236 | 242 | description: Paths delimited by comma (`,`) are no longer allowed. | |
| 237 | 243 | --> | |
| 238 | 244 | ||
| 239 | - > Stability: 1.1 - Active development | ||
| 245 | + > Stability: 2 - Stable. | ||
| 240 | 246 | ||
| 241 | 247 | This flag configures file system write permissions using | |
| 242 | 248 | the [Permission Model][]. | |
@@ -282,7 +288,7 @@ new WASI({ | |||
| 282 | 288 | ``` | |
| 283 | 289 | ||
| 284 | 290 | ```console | |
| 285 | - $ node --experimental-permission --allow-fs-read=* index.js | ||
| 291 | + $ node --permission --allow-fs-read=* index.js | ||
| 286 | 292 | ||
| 287 | 293 | Error: Access to this API has been restricted | |
| 288 | 294 | at node:internal/main/run_main_module:30:49 { | |
@@ -313,7 +319,7 @@ new Worker(__filename); | |||
| 313 | 319 | ``` | |
| 314 | 320 | ||
| 315 | 321 | ```console | |
| 316 | - $ node --experimental-permission --allow-fs-read=* index.js | ||
| 322 | + $ node --permission --allow-fs-read=* index.js | ||
| 317 | 323 | ||
| 318 | 324 | Error: Access to this API has been restricted | |
| 319 | 325 | at node:internal/main/run_main_module:17:47 { | |
@@ -949,24 +955,6 @@ added: | |||
| 949 | 955 | ||
| 950 | 956 | Enable experimental support for the network inspection with Chrome DevTools. | |
| 951 | 957 | ||
| 952 | - ### `--experimental-permission` | ||
| 953 | - | ||
| 954 | - <!-- YAML | ||
| 955 | - added: v20.0.0 | ||
| 956 | - --> | ||
| 957 | - | ||
| 958 | - > Stability: 1.1 - Active development | ||
| 959 | - | ||
| 960 | - Enable the Permission Model for current process. When enabled, the | ||
| 961 | - following permissions are restricted: | ||
| 962 | - | ||
| 963 | - * File System - manageable through | ||
| 964 | - [`--allow-fs-read`][], [`--allow-fs-write`][] flags | ||
| 965 | - * Child Process - manageable through [`--allow-child-process`][] flag | ||
| 966 | - * Worker Threads - manageable through [`--allow-worker`][] flag | ||
| 967 | - * WASI - manageable through [`--allow-wasi`][] flag | ||
| 968 | - * Addons - manageable through [`--allow-addons`][] flag | ||
| 969 | - | ||
| 970 | 958 | ### `--experimental-print-required-tla` | |
| 971 | 959 | ||
| 972 | 960 | <!-- YAML | |
@@ -1780,6 +1768,28 @@ unless either the `--pending-deprecation` command-line flag, or the | |||
| 1780 | 1768 | are used to provide a kind of selective "early warning" mechanism that | |
| 1781 | 1769 | developers may leverage to detect deprecated API usage. | |
| 1782 | 1770 | ||
| 1771 | + ### `--permission` | ||
| 1772 | + | ||
| 1773 | + <!-- YAML | ||
| 1774 | + added: v20.0.0 | ||
| 1775 | + changes: | ||
| 1776 | + - version: REPLACEME | ||
| 1777 | + pr-url: https://github.com/nodejs/node/pull/56201 | ||
| 1778 | + description: Permission Model is now stable. | ||
| 1779 | + --> | ||
| 1780 | + | ||
| 1781 | + > Stability: 2 - Stable. | ||
| 1782 | + | ||
| 1783 | + Enable the Permission Model for current process. When enabled, the | ||
| 1784 | + following permissions are restricted: | ||
| 1785 | + | ||
| 1786 | + * File System - manageable through | ||
| 1787 | + [`--allow-fs-read`][], [`--allow-fs-write`][] flags | ||
| 1788 | + * Child Process - manageable through [`--allow-child-process`][] flag | ||
| 1789 | + * Worker Threads - manageable through [`--allow-worker`][] flag | ||
| 1790 | + * WASI - manageable through [`--allow-wasi`][] flag | ||
| 1791 | + * Addons - manageable through [`--allow-addons`][] flag | ||
| 1792 | + | ||
| 1783 | 1793 | ### `--preserve-symlinks` | |
| 1784 | 1794 | ||
| 1785 | 1795 | <!-- YAML | |
@@ -3089,6 +3099,7 @@ one is included in the list below. | |||
| 3089 | 3099 | * `--openssl-legacy-provider` | |
| 3090 | 3100 | * `--openssl-shared-config` | |
| 3091 | 3101 | * `--pending-deprecation` | |
| 3102 | + * `--permission` | ||
| 3092 | 3103 | * `--preserve-symlinks-main` | |
| 3093 | 3104 | * `--preserve-symlinks` | |
| 3094 | 3105 | * `--prof-process` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,25 +28,25 @@ If you find a potential security vulnerability, please refer to our | |||
| 28 | 28 | ||
| 29 | 29 | <!-- type=misc --> | |
| 30 | 30 | ||
| 31 | - > Stability: 1.1 - Active development | ||
| 31 | + > Stability: 2 - Stable. | ||
| 32 | 32 | ||
| 33 | 33 | <!-- name=permission-model --> | |
| 34 | 34 | ||
| 35 | 35 | The Node.js Permission Model is a mechanism for restricting access to specific | |
| 36 | 36 | resources during execution. | |
| 37 | - The API exists behind a flag [`--experimental-permission`][] which when enabled, | ||
| 37 | + The API exists behind a flag [`--permission`][] which when enabled, | ||
| 38 | 38 | will restrict access to all available permissions. | |
| 39 | 39 | ||
| 40 | - The available permissions are documented by the [`--experimental-permission`][] | ||
| 40 | + The available permissions are documented by the [`--permission`][] | ||
| 41 | 41 | flag. | |
| 42 | 42 | ||
| 43 | - When starting Node.js with `--experimental-permission`, | ||
| 43 | + When starting Node.js with `--permission`, | ||
| 44 | 44 | the ability to access the file system through the `fs` module, spawn processes, | |
| 45 | 45 | use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector | |
| 46 | 46 | will be restricted. | |
| 47 | 47 | ||
| 48 | 48 | ```console | |
| 49 | - $ node --experimental-permission index.js | ||
| 49 | + $ node --permission index.js | ||
| 50 | 50 | ||
| 51 | 51 | Error: Access to this API has been restricted | |
| 52 | 52 | at node:internal/main/run_main_module:23:47 { | |
@@ -64,7 +64,7 @@ flag. For WASI, use the [`--allow-wasi`][] flag. | |||
| 64 | 64 | ||
| 65 | 65 | #### Runtime API | |
| 66 | 66 | ||
| 67 | - When enabling the Permission Model through the [`--experimental-permission`][] | ||
| 67 | + When enabling the Permission Model through the [`--permission`][] | ||
| 68 | 68 | flag a new property `permission` is added to the `process` object. | |
| 69 | 69 | This property contains one function: | |
| 70 | 70 | ||
@@ -90,10 +90,8 @@ To allow access to the file system, use the [`--allow-fs-read`][] and | |||
| 90 | 90 | [`--allow-fs-write`][] flags: | |
| 91 | 91 | ||
| 92 | 92 | ```console | |
| 93 | - $ node --experimental-permission --allow-fs-read=* --allow-fs-write=* index.js | ||
| 93 | + $ node --permission --allow-fs-read=* --allow-fs-write=* index.js | ||
| 94 | 94 | Hello world! | |
| 95 | - (node:19836) ExperimentalWarning: Permission is an experimental feature | ||
| 96 | - (Use `node --trace-warnings ...` to show where the warning was created) | ||
| 97 | 95 | ``` | |
| 98 | 96 | ||
| 99 | 97 | The valid arguments for both flags are: | |
@@ -167,5 +165,5 @@ There are constraints you need to know before using this system: | |||
| 167 | 165 | [`--allow-fs-write`]: cli.md#--allow-fs-write | |
| 168 | 166 | [`--allow-wasi`]: cli.md#--allow-wasi | |
| 169 | 167 | [`--allow-worker`]: cli.md#--allow-worker | |
| 170 | - [`--experimental-permission`]: cli.md#--experimental-permission | ||
| 168 | + [`--permission`]: cli.md#--permission | ||
| 171 | 169 | [`permission.has()`]: process.md#processpermissionhasscope-reference | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3103,7 +3103,7 @@ added: v20.0.0 | |||
| 3103 | 3103 | ||
| 3104 | 3104 | * {Object} | |
| 3105 | 3105 | ||
| 3106 | - This API is available through the [`--experimental-permission`][] flag. | ||
| 3106 | + This API is available through the [`--permission`][] flag. | ||
| 3107 | 3107 | ||
| 3108 | 3108 | `process.permission` is an object whose methods are used to manage permissions | |
| 3109 | 3109 | for the current process. Additional documentation is available in the | |
@@ -4440,8 +4440,8 @@ cases: | |||
| 4440 | 4440 | [`'exit'`]: #event-exit | |
| 4441 | 4441 | [`'message'`]: child_process.md#event-message | |
| 4442 | 4442 | [`'uncaughtException'`]: #event-uncaughtexception | |
| 4443 | - [`--experimental-permission`]: cli.md#--experimental-permission | ||
| 4444 | 4443 | [`--no-deprecation`]: cli.md#--no-deprecation | |
| 4444 | + [`--permission`]: cli.md#--permission | ||
| 4445 | 4445 | [`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode | |
| 4446 | 4446 | [`Buffer`]: buffer.md | |
| 4447 | 4447 | [`ChildProcess.disconnect()`]: child_process.md#subprocessdisconnect | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,8 +171,8 @@ Specify the | |||
| 171 | 171 | .Ar module | |
| 172 | 172 | to use as a custom module loader. | |
| 173 | 173 | . | |
| 174 | - .It Fl -experimental-permission | ||
| 175 | - Enable the experimental permission model. | ||
| 174 | + .It Fl -permission | ||
| 175 | + Enable the permission model. | ||
| 176 | 176 | . | |
| 177 | 177 | .It Fl -experimental-shadow-realm | |
| 178 | 178 | Use this flag to enable ShadowRealm support. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,16 +9,16 @@ const { validateString, validateBuffer } = require('internal/validators'); | |||
| 9 | 9 | const { Buffer } = require('buffer'); | |
| 10 | 10 | const { isBuffer } = Buffer; | |
| 11 | 11 | ||
| 12 | - let experimentalPermission; | ||
| 12 | + let _permission; | ||
| 13 | 13 | ||
| 14 | 14 | module.exports = ObjectFreeze({ | |
| 15 | 15 | __proto__: null, | |
| 16 | 16 | isEnabled() { | |
| 17 | - if (experimentalPermission === undefined) { | ||
| 17 | + if (_permission === undefined) { | ||
| 18 | 18 | const { getOptionValue } = require('internal/options'); | |
| 19 | - experimentalPermission = getOptionValue('--experimental-permission'); | ||
| 19 | + _permission = getOptionValue('--permission'); | ||
| 20 | 20 | } | |
| 21 | - return experimentalPermission; | ||
| 21 | + return _permission; | ||
| 22 | 22 | }, | |
| 23 | 23 | has(scope, reference) { | |
| 24 | 24 | validateString(scope, 'scope'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -520,14 +520,13 @@ function initializeClusterIPC() { | |||
| 520 | 520 | } | |
| 521 | 521 | ||
| 522 | 522 | function initializePermission() { | |
| 523 | - const experimentalPermission = getOptionValue('--experimental-permission'); | ||
| 524 | - if (experimentalPermission) { | ||
| 523 | + const permission = getOptionValue('--permission'); | ||
| 524 | + if (permission) { | ||
| 525 | 525 | process.binding = function binding(_module) { | |
| 526 | 526 | throw new ERR_ACCESS_DENIED('process.binding'); | |
| 527 | 527 | }; | |
| 528 | 528 | // Guarantee path module isn't monkey-patched to bypass permission model | |
| 529 | 529 | ObjectFreeze(require('path')); | |
| 530 | - emitExperimentalWarning('Permission'); | ||
| 531 | 530 | const { has } = require('internal/process/permission'); | |
| 532 | 531 | const warnFlags = [ | |
| 533 | 532 | '--allow-addons', | |
@@ -579,7 +578,7 @@ function initializePermission() { | |||
| 579 | 578 | ArrayPrototypeForEach(availablePermissionFlags, (flag) => { | |
| 580 | 579 | const value = getOptionValue(flag); | |
| 581 | 580 | if (value.length) { | |
| 582 | - throw new ERR_MISSING_OPTION('--experimental-permission'); | ||
| 581 | + throw new ERR_MISSING_OPTION('--permission'); | ||
| 583 | 582 | } | |
| 584 | 583 | }); | |
| 585 | 584 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -920,7 +920,7 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 920 | 920 | std::move(traced_value)); | |
| 921 | 921 | } | |
| 922 | 922 | ||
| 923 | - if (options_->experimental_permission) { | ||
| 923 | + if (options_->permission) { | ||
| 924 | 924 | permission()->EnablePermissions(); | |
| 925 | 925 | // The process shouldn't be able to neither | |
| 926 | 926 | // spawn/worker nor use addons or enable inspector | |
| Back | FazBrowse Home | New Git URL |
0 commit comments