Skip to content

Commit

Permalink
test,doc: clarify wildcard usage
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Feb 14, 2024
1 parent 10ecf40 commit 834ae37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/api/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ Wildcards are supported too:
* `--allow-fs-read=/home/test*` will allow read access to everything
that matches the wildcard. e.g: `/home/test/file1` or `/home/test2`

After passing a wildcard character (`*`) all subsequent characters will
be ignored. For example: `/home/*.js` will work similar to `/home/*`.

#### Permission Model constraints

There are constraints you need to know before using this system:
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-permission-fs-wildcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ if (common.isWindows) {
'--experimental-permission',
'--allow-fs-read=/a/b/*',
'--allow-fs-read=/a/b/d',
'--allow-fs-read=/etc/passwd.*',
'--allow-fs-read=/home/*.js',
'-e',
`
const assert = require('assert')
assert.ok(process.permission.has('fs.read', '/a/b/c'));
assert.ok(!process.permission.has('fs.read', '/a/c/c'));
assert.ok(!process.permission.has('fs.read', '/etc/passwd'));
assert.ok(process.permission.has('fs.read', '/home/another-file.md'));
`,
]
);
Expand Down

0 comments on commit 834ae37

Please sign in to comment.