Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit 30ae8ab

Browse files
edsadraduh95
authored andcommitted
doc: document --permission-audit audit mode behavior
Expand the documentation for the --permission-audit flag, which was fixed in 51c09ea to no longer throw ERR_ACCESS_DENIED on denied operations. The previous docs only had a two-sentence description in cli.md and no mention in the permissions guide or process.permission API docs. - permissions.md: add enforce vs audit mode overview, a new "Audit Mode" subsection listing the diagnostics channel names (node:permission-model:*) and the { permission, resource } message shape, and a usage example. Update the Runtime API section to mention both --permission and --permission-audit. - cli.md: expand the --permission-audit section to clarify that --permission is not required, --allow-* flags are not needed, errors are not thrown, and --permission takes precedence when both are set. Add a cross-reference from --permission to --permission-audit. - process.md: note that process.permission is available under both flags, and clarify permission.has() and permission.drop() behavior in audit mode. - node.1: regenerated via `make node.1`. Refs: #64426 Signed-off-by: Adrian Estrada <edsadr@gmail.com> PR-URL: #64791 Backport-PR-URL: #65354 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d53d582 commit 30ae8ab

4 files changed

Lines changed: 103 additions & 9 deletions

File tree

β€Ždoc/api/cli.mdβ€Ž

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ changes:
21302130
Enable the Permission Model for current process. When enabled, the
21312131
following permissions are restricted:
21322132

2133+
> See also [`--permission-audit`](#--permission-audit) for an audit-only mode
2134+
> that logs violations without denying access.
2135+
21332136
* File System - manageable through
21342137
[`--allow-fs-read`][], [`--allow-fs-write`][] flags
21352138
* Child Process - manageable through [`--allow-child-process`][] flag
@@ -2143,9 +2146,22 @@ following permissions are restricted:
21432146
added: REPLACEME
21442147
-->
21452148

2146-
Enable audit only for the permission model. When enabled, permission checks
2147-
are performed but access is not denied. Instead, a warning is emitted for
2148-
each permission violation via diagnostics channel.
2149+
Enable audit mode for the permission model. When enabled, permission checks
2150+
are performed but access is **not** denied β€” no `ERR_ACCESS_DENIED` error is
2151+
thrown. Instead, each permission violation is published through the
2152+
`node:diagnostics_channel` module, and execution continues normally.
2153+
2154+
This flag does not require [`--permission`](#--permission) to be specified. The
2155+
`--allow-*` flags are not needed in audit mode, since no
2156+
access is denied.
2157+
2158+
Audit mode is useful for discovering what permissions your application
2159+
requires before deploying with [`--permission`](#--permission). See the
2160+
[Permission Model][] documentation for the list of diagnostics channel names
2161+
and the message format.
2162+
2163+
If both [`--permission`](#--permission) and `--permission-audit` are specified,
2164+
`--permission` takes precedence and the Permission Model runs in enforce mode.
21492165

21502166
### `--preserve-symlinks`
21512167

β€Ždoc/api/permissions.mdβ€Ž

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ will restrict access to all available permissions.
4848
The available permissions are documented by the [`--permission`][]
4949
flag.
5050

51+
The Permission Model has two operational modes:
52+
53+
***Enforce mode** (default when using [`--permission`][]): Access is denied and
54+
an `ERR_ACCESS_DENIED` error is thrown for any operation the process has not
55+
been granted permission to perform.
56+
***Audit mode** (when using [`--permission-audit`][]): Permission checks are
57+
performed and violations are published through the diagnostics channel, but
58+
access is **not** denied. Execution continues normally. This mode is useful
59+
for discovering what permissions your application requires before deploying
60+
with enforce mode.
61+
5162
When starting Node.js with `--permission`,
5263
the ability to access the file system through the `fs` module, spawn processes,
5364
use `node:worker_threads`, use native addons, use WASI, and enable the runtime inspector
@@ -73,8 +84,8 @@ flag. For WASI, use the [`--allow-wasi`][] flag.
7384
#### Runtime API
7485

7586
When enabling the Permission Model through the [`--permission`][]
76-
flag a new property `permission` is added to the`process` object.
77-
This property contains the following functions:
87+
or [`--permission-audit`][] flags, a new property `permission` is added to the
88+
`process` object. This property contains the following functions:
7889

7990
##### `permission.has(scope[, reference])`
8091

@@ -122,6 +133,53 @@ process.permission.has('fs.read', '/etc/myapp/config.json'); // false
122133
process.permission.drop('child');
123134
```
124135

136+
#### Audit Mode
137+
138+
The [`--permission-audit`][] flag enables audit mode for the Permission Model.
139+
In audit mode, permission checks are performed but access is **not** denied β€”
140+
no `ERR_ACCESS_DENIED` error is thrown. Instead, each permission violation is
141+
published through the `node:diagnostics_channel` module, allowing the
142+
application to observe and log which operations would be denied under enforce
143+
mode. Execution continues normally.
144+
145+
Audit mode is useful for discovering what permissions your application
146+
requires before deploying with [`--permission`][]. It can also be combined
147+
with the [`--allow-fs-read`][], [`--allow-fs-write`][],
148+
[`--allow-child-process`][], [`--allow-worker`][], [`--allow-addons`][], and
149+
[`--allow-wasi`][] flags to audit a subset of permissions while granting
150+
others.
151+
152+
When a permission check fails in audit mode, a message is published to the
153+
diagnostics channel corresponding to the denied scope. The channel names are:
154+
155+
*`node:permission-model:fs` β€” File System (read and write)
156+
*`node:permission-model:child` β€” Child Process
157+
*`node:permission-model:worker` β€” Worker Threads
158+
*`node:permission-model:inspector` β€” Inspector
159+
*`node:permission-model:wasi` β€” WASI
160+
*`node:permission-model:addon` β€” Native Addons
161+
162+
Each message is an object with the following properties:
163+
164+
*`permission` {string} The name of the denied permission scope.
165+
*`resource` {string} The resource that access was denied to (e.g. a file path).
166+
167+
```js
168+
constdiagnostics_channel=require('node:diagnostics_channel');
169+
170+
diagnostics_channel.channel('node:permission-model:fs').subscribe((msg) => {
171+
console.log(`Permission denied: ${msg.permission} on ${msg.resource}`);
172+
});
173+
174+
// Running with --permission-audit, this publishes a diagnostics channel
175+
// message but does not throw
176+
constfs=require('node:fs');
177+
fs.readFileSync('/etc/passwd');
178+
```
179+
180+
If both [`--permission`][] and [`--permission-audit`][] are specified,
181+
`--permission` takes precedence and the Permission Model runs in enforce mode.
182+
125183
#### File System Permissions
126184

127185
The Permission Model, by default, restricts access to the file system through the `node:fs` module.
@@ -312,6 +370,7 @@ Developers relying on --permission to sandbox untrusted code should be aware tha
312370
[`--allow-fs-write`]: cli.md#--allow-fs-write
313371
[`--allow-wasi`]: cli.md#--allow-wasi
314372
[`--allow-worker`]: cli.md#--allow-worker
373+
[`--permission-audit`]: cli.md#--permission-audit
315374
[`--permission`]: cli.md#--permission
316375
[`npx`]: https://docs.npmjs.com/cli/commands/npx
317376
[`permission.has()`]: process.md#processpermissionhasscope-reference

β€Ždoc/api/process.mdβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,8 @@ added: v20.0.0
31503150
31513151
* Type: {Object}
31523152
3153-
This API is available through the [`--permission`][] flag.
3153+
This API is available through the [`--permission`][] or
3154+
[`--permission-audit`][] flags.
31543155
31553156
`process.permission` is an object whose methods are used to manage permissions
31563157
for the current process. Additional documentation is available in the
@@ -3171,6 +3172,9 @@ If no reference is provided, a global scope is assumed, for instance,
31713172
`process.permission.has('fs.read')` will check if the process has ALL
31723173
file system read permissions.
31733174
3175+
In audit mode ([`--permission-audit`][]), this method still returns the actual
3176+
permission status, but denied operations will not throw `ERR_ACCESS_DENIED`.
3177+
31743178
The reference has a meaning based on the provided scope. For example,
31753179
the reference when the scope is File System means files and folders.
31763180
@@ -3204,6 +3208,10 @@ Drops the specified permission from the current process. This operation is
32043208
**irreversible** β€” once a permission is dropped, it cannot be restored through
32053209
any Node.js API.
32063210
3211+
In audit mode ([`--permission-audit`][]), dropping a permission takes effect,
3212+
but since denied operations do not throw, the impact is limited to changing the
3213+
return value of `permission.has()`.
3214+
32073215
If no reference is provided, the entire scope is dropped. For example,
32083216
`process.permission.drop('fs.read')` will revoke ALL file system read
32093217
permissions.
@@ -4626,6 +4634,7 @@ cases:
46264634
[`'message'`]: child_process.md#event-message
46274635
[`'uncaughtException'`]: #event-uncaughtexception
46284636
[`--no-deprecation`]: cli.md#--no-deprecation
4637+
[`--permission-audit`]: cli.md#--permission-audit
46294638
[`--permission`]: cli.md#--permission
46304639
[`--unhandled-rejections`]: cli.md#--unhandled-rejectionsmode
46314640
[`Buffer`]: buffer.md

β€Ždoc/node.1β€Ž

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is
469469
Emit pending deprecation warnings.
470470
.
471471
.ItFl-permission-audit
472-
Enable audit only for the permission model. When enabled, permission checks
473-
are performed but access is not denied. Instead, a warning is emitted for
474-
each permission violation via diagnostics channel.
472+
Enable audit mode for the permission model. When enabled, permission checks
473+
are performed but access is \fBnot\fR denied β€” no \fBERR_ACCESS_DENIED\fR error is
474+
thrown. Instead, each permission violation is published through the
475+
\fBnode:diagnostics_channel\fR module, and execution continues normally.
476+
This flag does not require \fB--permission\fR to be specified. The
477+
\fB--allow-*\fR flags are not needed in audit mode, since no
478+
access is denied.
479+
Audit mode is useful for discovering what permissions your application
480+
requires before deploying with \fB--permission\fR. See the
481+
Permission Model documentation for the list of diagnostics channel names
482+
and the message format.
483+
If both \fB--permission\fR and \fB--permission-audit\fR are specified,
484+
\fB--permission\fR takes precedence and the Permission Model runs in enforce mode.
475485
.
476486
.ItFl-preserve-symlinks
477487
Instructs the module loader to preserve symbolic links when resolving and caching modules other than the main module.

0 commit comments

Comments
Β (0)