src,permission: add --allow-inspector ability · nodejs/node@92ea669 · GitHub
Skip to content

Commit 92ea669

Browse files
RafaelGSStargos
authored andcommitted
src,permission: add --allow-inspector ability
Refs: #48534 PR-URL: #59711 Backport-PR-URL: #60248 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
1 parent 1e9abe0 commit 92ea669

13 files changed

Lines changed: 110 additions & 4 deletions

doc/api/cli.md

Lines changed: 31 additions & 0 deletions

doc/node-config-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
}
4646
]
4747
},
48+
"allow-inspector": {
49+
"type": "boolean"
50+
},
4851
"allow-wasi": {
4952
"type": "boolean"
5053
},

doc/node.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ Allow using native addons when using the permission model.
8585
.It Fl -allow-child-process
8686
Allow spawning process when using the permission model.
8787
.
88+
.It Fl -allow-inspector
89+
Allow inspector access when using the permission model.
90+
.
8891
.It Fl -allow-wasi
8992
Allow execution of WASI when using the permission model.
9093
.

lib/internal/process/permission.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = ObjectFreeze({
3939
'--allow-fs-write',
4040
'--allow-addons',
4141
'--allow-child-process',
42+
'--allow-inspector',
4243
'--allow-wasi',
4344
'--allow-worker',
4445
];

lib/internal/process/pre_execution.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ function initializePermission() {
613613
const warnFlags = [
614614
'--allow-addons',
615615
'--allow-child-process',
616+
'--allow-inspector',
616617
'--allow-wasi',
617618
'--allow-worker',
618619
];

src/env.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,10 @@ Environment::Environment(IsolateData* isolate_data,
912912
options_->allow_native_addons = false;
913913
permission()->Apply(this, {"*"}, permission::PermissionScope::kAddon);
914914
}
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+
}
917919
if (!options_->allow_child_process) {
918920
permission()->Apply(
919921
this, {"*"}, permission::PermissionScope::kChildProcess);

src/node_options.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
614614
"allow use of child process when any permissions are set",
615615
&EnvironmentOptions::allow_child_process,
616616
kAllowedInEnvvar);
617+
AddOption("--allow-inspector",
618+
"allow use of inspector when any permissions are set",
619+
&EnvironmentOptions::allow_inspector,
620+
kAllowedInEnvvar);
617621
AddOption("--allow-wasi",
618622
"allow wasi when any permissions are set",
619623
&EnvironmentOptions::allow_wasi,

src/node_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class EnvironmentOptions : public Options {
140140
std::vector<std::string> allow_fs_read;
141141
std::vector<std::string> allow_fs_write;
142142
bool allow_addons = false;
143+
bool allow_inspector = false;
143144
bool allow_child_process = false;
144145
bool allow_wasi = false;
145146
bool allow_worker_threads = false;

src/permission/permission_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace permission {
2727
#define WORKER_THREADS_PERMISSIONS(V) \
2828
V(WorkerThreads, "worker", PermissionsRoot, "--allow-worker")
2929

30-
#define INSPECTOR_PERMISSIONS(V) V(Inspector, "inspector", PermissionsRoot, "")
30+
#define INSPECTOR_PERMISSIONS(V) \
31+
V(Inspector, "inspector", PermissionsRoot, "--allow-inspector")
3132

3233
#define ADDON_PERMISSIONS(V) \
3334
V(Addon, "addon", PermissionsRoot, "--allow-addons")

test/common/index.js

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)