From c8316fecbda3727d2097805b2c16037bc1bd63f1 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Thu, 11 Sep 2025 17:10:02 -0300 Subject: [PATCH] src,permission: add --allow-inspector ability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/issues/48534 PR-URL: https://github.com/nodejs/node/pull/59711 Reviewed-By: Santiago Gimeno Reviewed-By: Juan José Arboleda Signed-off-by: RafaelGSS --- doc/api/cli.md | 31 +++++++++++ doc/node-config-schema.json | 3 + doc/node.1 | 3 + lib/internal/process/permission.js | 1 + lib/internal/process/pre_execution.js | 1 + src/env.cc | 6 +- src/node_options.cc | 4 ++ src/node_options.h | 1 + src/permission/permission_base.h | 3 +- test/common/index.js | 3 + .../test-permission-allow-inspector.js | 55 +++++++++++++++++++ test/parallel/test-permission-inspector.js | 2 +- .../parallel/test-permission-warning-flags.js | 1 + 13 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 test/parallel/test-permission-allow-inspector.js diff --git a/doc/api/cli.md b/doc/api/cli.md index cc990c01704484..81e57322255ec2 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -271,6 +271,36 @@ When passing a single flag with a comma a warning will be displayed. Examples can be found in the [File System Permissions][] documentation. +### `--allow-inspector` + + + +> Stability: 1.0 - Early development + +When using the [Permission Model][], the process will not be able to connect +through inspector protocol. + +Attempts to do so will throw an `ERR_ACCESS_DENIED` unless the +user explicitly passes the `--allow-inspector` flag when starting Node.js. + +Example: + +```js +const { Session } = require('node:inspector/promises'); + +const session = new Session(); +session.connect(); +``` + +```console +$ node --permission index.js +Error: connect ERR_ACCESS_DENIED Access to this API has been restricted. Use --allow-inspector to manage permissions. + code: 'ERR_ACCESS_DENIED', +} +``` + ### `--allow-wasi`