@@ -492,24 +492,7 @@ using the [`--allow-child-process`][] and [`--allow-worker`][] respectively.
492492
493493When enabling the Permission Model through the [ ` --experimental-permission ` ] [ ]
494494flag a new property ` permission ` is added to the ` process ` object.
495- This property contains two functions:
496-
497- ##### ` permission.deny(scope [,parameters]) `
498-
499- API call to deny permissions at runtime ([ ` permission.deny() ` ] [ ] )
500-
501- ``` js
502- process .permission .deny (' fs' ); // Deny permissions to ALL fs operations
503-
504- // Deny permissions to ALL FileSystemWrite operations
505- process .permission .deny (' fs.write' );
506- // deny FileSystemWrite permissions to the protected-folder
507- process .permission .deny (' fs.write' , [' /home/rafaelgss/protected-folder' ]);
508- // Deny permissions to ALL FileSystemRead operations
509- process .permission .deny (' fs.read' );
510- // deny FileSystemRead permissions to the protected-folder
511- process .permission .deny (' fs.read' , [' /home/rafaelgss/protected-folder' ]);
512- ```
495+ This property contains one function:
513496
514497##### ` permission.has(scope ,parameters) `
515498
@@ -519,10 +502,8 @@ API call to check permissions at runtime ([`permission.has()`][])
519502process .permission .has (' fs.write' ); // true
520503process .permission .has (' fs.write' , ' /home/rafaelgss/protected-folder' ); // true
521504
522- process .permission .deny (' fs.write' , ' /home/rafaelgss/protected-folder' );
523-
524- process .permission .has (' fs.write' ); // true
525- process .permission .has (' fs.write' , ' /home/rafaelgss/protected-folder' ); // false
505+ process .permission .has (' fs.read' ); // true
506+ process .permission .has (' fs.read' , ' /home/rafaelgss/protected-folder' ); // false
526507```
527508
528509#### File System Permissions
@@ -560,39 +541,18 @@ There are constraints you need to know before using this system:
560541
561542* Native modules are restricted by default when using the Permission Model.
562543* Relative paths are not supported through the CLI (` --allow-fs-* ` ).
563- The runtime API supports relative paths.
564544* The model does not inherit to a child node process.
565545* The model does not inherit to a worker thread.
566546* When creating symlinks the target (first argument) should have read and
567547 write access.
568548* Permission changes are not retroactively applied to existing resources.
569- Consider the following snippet:
570- ``` js
571- const fs = require (' node:fs' );
572-
573- // Open a fd
574- const fd = fs .openSync (' ./README.md' , ' r' );
575- // Then, deny access to all fs.read operations
576- process .permission .deny (' fs.read' );
577- // This call will NOT fail and the file will be read
578- const data = fs .readFileSync (fd);
579- ```
580-
581- Therefore, when possible, apply the permissions rules before any statement:
582-
583- ``` js
584- process .permission .deny (' fs.read' );
585- const fd = fs .openSync (' ./README.md' , ' r' );
586- // Error: Access to this API has been restricted
587- ```
588549
589550[ Security Policy ] : https://github.com/nodejs/node/blob/main/SECURITY.md
590551[ `--allow-child-process` ] : cli.md#--allow-child-process
591552[ `--allow-fs-read` ] : cli.md#--allow-fs-read
592553[ `--allow-fs-write` ] : cli.md#--allow-fs-write
593554[ `--allow-worker` ] : cli.md#--allow-worker
594555[ `--experimental-permission` ] : cli.md#--experimental-permission
595- [ `permission.deny()` ] : process.md#processpermissiondenyscope-reference
596556[ `permission.has()` ] : process.md#processpermissionhasscope-reference
597557[ import maps ] : https://url.spec.whatwg.org/#relative-url-with-fragment-string
598558[ relative-url string ] : https://url.spec.whatwg.org/#relative-url-with-fragment-string
0 commit comments