| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -275,6 +275,36 @@ When passing a single flag with a comma a warning will be displayed. | |||
| 275 | 275 | ||
| 276 | 276 | Examples can be found in the [File System Permissions][] documentation. | |
| 277 | 277 | ||
| 278 | + ### `--allow-inspector` | ||
| 279 | + | ||
| 280 | + <!-- YAML | ||
| 281 | + added: REPLACEME | ||
| 282 | + --> | ||
| 283 | + | ||
| 284 | + > Stability: 1.0 - Early development | ||
| 285 | + | ||
| 286 | + When using the [Permission Model][], the process will not be able to connect | ||
| 287 | + through inspector protocol. | ||
| 288 | + | ||
| 289 | + Attempts to do so will throw an `ERR_ACCESS_DENIED` unless the | ||
| 290 | + user explicitly passes the `--allow-inspector` flag when starting Node.js. | ||
| 291 | + | ||
| 292 | + Example: | ||
| 293 | + | ||
| 294 | + ```js | ||
| 295 | + const { Session } = require('node:inspector/promises'); | ||
| 296 | + | ||
| 297 | + const session = new Session(); | ||
| 298 | + session.connect(); | ||
| 299 | + ``` | ||
| 300 | + | ||
| 301 | + ```console | ||
| 302 | + $ node --permission index.js | ||
| 303 | + Error: connect ERR_ACCESS_DENIED Access to this API has been restricted. Use --allow-inspector to manage permissions. | ||
| 304 | + code: 'ERR_ACCESS_DENIED', | ||
| 305 | + } | ||
| 306 | + ``` | ||
| 307 | + | ||
| 278 | 308 | ### `--allow-net` | |
| 279 | 309 | ||
| 280 | 310 | <!-- YAML | |
@@ -3427,6 +3457,7 @@ one is included in the list below. | |||
| 3427 | 3457 | * `--allow-child-process` | |
| 3428 | 3458 | * `--allow-fs-read` | |
| 3429 | 3459 | * `--allow-fs-write` | |
| 3460 | + * `--allow-inspector` | ||
| 3430 | 3461 | * `--allow-net` | |
| 3431 | 3462 | * `--allow-wasi` | |
| 3432 | 3463 | * `--allow-worker` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,8 @@ flag. | |||
| 51 | 51 | When starting Node.js with `--permission`, | |
| 52 | 52 | the ability to access the file system through the `fs` module, access the network, | |
| 53 | 53 | spawn processes, use `node:worker_threads`, use native addons, use WASI, and | |
| 54 | - enable the runtime inspector will be restricted. | ||
| 54 | + enable the runtime inspector will be restricted (the listener for SIGUSR1 won't | ||
| 55 | + be created). | ||
| 55 | 56 | ||
| 56 | 57 | ```console | |
| 57 | 58 | $ node --permission index.js | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,9 @@ | |||
| 45 | 45 | } | |
| 46 | 46 | ] | |
| 47 | 47 | }, | |
| 48 | + "allow-inspector": { | ||
| 49 | + "type": "boolean" | ||
| 50 | + }, | ||
| 48 | 51 | "allow-net": { | |
| 49 | 52 | "type": "boolean" | |
| 50 | 53 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,6 +85,9 @@ Allow using native addons when using the permission model. | |||
| 85 | 85 | .It Fl -allow-child-process | |
| 86 | 86 | Allow spawning process when using the permission model. | |
| 87 | 87 | . | |
| 88 | + .It Fl -allow-inspector | ||
| 89 | + Allow inspector access when using the permission model. | ||
| 90 | + . | ||
| 88 | 91 | .It Fl -allow-net | |
| 89 | 92 | Allow network access when using the permission model. | |
| 90 | 93 | . | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ module.exports = ObjectFreeze({ | |||
| 40 | 40 | '--allow-addons', | |
| 41 | 41 | '--allow-child-process', | |
| 42 | 42 | '--allow-net', | |
| 43 | + '--allow-inspector', | ||
| 43 | 44 | '--allow-wasi', | |
| 44 | 45 | '--allow-worker', | |
| 45 | 46 | ]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -580,6 +580,7 @@ function initializePermission() { | |||
| 580 | 580 | const warnFlags = [ | |
| 581 | 581 | '--allow-addons', | |
| 582 | 582 | '--allow-child-process', | |
| 583 | + '--allow-inspector', | ||
| 583 | 584 | '--allow-wasi', | |
| 584 | 585 | '--allow-worker', | |
| 585 | 586 | ]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -912,8 +912,10 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 912 | 912 | options_->allow_native_addons = false; | |
| 913 | 913 | permission()->Apply(this, {"*"}, permission::PermissionScope::kAddon); | |
| 914 | 914 | } | |
| 915 | - flags_ = flags_ | EnvironmentFlags::kNoCreateInspector; | ||
| 916 | - permission()->Apply(this, {"*"}, permission::PermissionScope::kInspector); | ||
| 915 | + if (!options_->allow_inspector) { | ||
| 916 | + flags_ = flags_ | EnvironmentFlags::kNoCreateInspector; | ||
| 917 | + permission()->Apply(this, {"*"}, permission::PermissionScope::kInspector); | ||
| 918 | + } | ||
| 917 | 919 | if (!options_->allow_child_process) { | |
| 918 | 920 | permission()->Apply( | |
| 919 | 921 | this, {"*"}, permission::PermissionScope::kChildProcess); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -606,6 +606,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | |||
| 606 | 606 | "allow use of child process when any permissions are set", | |
| 607 | 607 | &EnvironmentOptions::allow_child_process, | |
| 608 | 608 | kAllowedInEnvvar); | |
| 609 | + AddOption("--allow-inspector", | ||
| 610 | + "allow use of inspector when any permissions are set", | ||
| 611 | + &EnvironmentOptions::allow_inspector, | ||
| 612 | + kAllowedInEnvvar); | ||
| 609 | 613 | AddOption("--allow-net", | |
| 610 | 614 | "allow use of network when any permissions are set", | |
| 611 | 615 | &EnvironmentOptions::allow_net, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,6 +141,7 @@ class EnvironmentOptions : public Options { | |||
| 141 | 141 | std::vector<std::string> allow_fs_read; | |
| 142 | 142 | std::vector<std::string> allow_fs_write; | |
| 143 | 143 | bool allow_addons = false; | |
| 144 | + bool allow_inspector = false; | ||
| 144 | 145 | bool allow_child_process = false; | |
| 145 | 146 | bool allow_net = false; | |
| 146 | 147 | bool allow_wasi = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,8 @@ namespace permission { | |||
| 27 | 27 | #define WORKER_THREADS_PERMISSIONS(V) \ | |
| 28 | 28 | V(WorkerThreads, "worker", PermissionsRoot, "--allow-worker") | |
| 29 | 29 | ||
| 30 | - #define INSPECTOR_PERMISSIONS(V) V(Inspector, "inspector", PermissionsRoot, "") | ||
| 30 | + #define INSPECTOR_PERMISSIONS(V) \ | ||
| 31 | + V(Inspector, "inspector", PermissionsRoot, "--allow-inspector") | ||
| 31 | 32 | ||
| 32 | 33 | #define NET_PERMISSIONS(V) V(Net, "net", PermissionsRoot, "--allow-net") | |
| 33 | 34 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments