From 23cb9f3809886e4e2e630e9440eeae612214d2af Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Mon, 1 Sep 2025 17:20:02 -0300 Subject: [PATCH 1/2] src,permission: add --allow-inspector ability Refs: https://github.com/nodejs/node/issues/48534 --- 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 | 53 +++++++++++++++++++ test/parallel/test-permission-inspector.js | 2 +- .../parallel/test-permission-warning-flags.js | 1 + 13 files changed, 108 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 311a2ca2674453..415136a5868e20 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -275,6 +275,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-net`