-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src,permission: add multiple allow-fs-* flags
Support for a single comma separates list for allow-fs-* flags is removed. Instead now multiple flags can be passed to allow multiple paths. Fixes: nodejs/security-wg#1039 PR-URL: #49047 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
- Loading branch information
1 parent
ceaa549
commit ec51e25
Showing
24 changed files
with
161 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const { spawnSync } = require('child_process'); | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
|
||
{ | ||
const tmpPath = path.resolve('/tmp/'); | ||
const otherPath = path.resolve('/other-path/'); | ||
const { status, stdout } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-write', tmpPath, '--allow-fs-write', otherPath, '-e', | ||
`console.log(process.permission.has("fs")); | ||
console.log(process.permission.has("fs.read")); | ||
console.log(process.permission.has("fs.write")); | ||
console.log(process.permission.has("fs.write", "/tmp/")); | ||
console.log(process.permission.has("fs.write", "/other-path/"));`, | ||
] | ||
); | ||
const [fs, fsIn, fsOut, fsOutAllowed1, fsOutAllowed2] = stdout.toString().split('\n'); | ||
assert.strictEqual(fs, 'false'); | ||
assert.strictEqual(fsIn, 'false'); | ||
assert.strictEqual(fsOut, 'false'); | ||
assert.strictEqual(fsOutAllowed1, 'true'); | ||
assert.strictEqual(fsOutAllowed2, 'true'); | ||
assert.strictEqual(status, 0); | ||
} | ||
|
||
{ | ||
const tmpPath = path.resolve('/tmp/'); | ||
const pathWithComma = path.resolve('/other,path/'); | ||
const { status, stdout } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-write', | ||
tmpPath, | ||
'--allow-fs-write', | ||
pathWithComma, | ||
'-e', | ||
`console.log(process.permission.has("fs")); | ||
console.log(process.permission.has("fs.read")); | ||
console.log(process.permission.has("fs.write")); | ||
console.log(process.permission.has("fs.write", "/tmp/")); | ||
console.log(process.permission.has("fs.write", "/other,path/"));`, | ||
] | ||
); | ||
const [fs, fsIn, fsOut, fsOutAllowed1, fsOutAllowed2] = stdout.toString().split('\n'); | ||
assert.strictEqual(fs, 'false'); | ||
assert.strictEqual(fsIn, 'false'); | ||
assert.strictEqual(fsOut, 'false'); | ||
assert.strictEqual(fsOutAllowed1, 'true'); | ||
assert.strictEqual(fsOutAllowed2, 'true'); | ||
assert.strictEqual(status, 0); | ||
} | ||
|
||
{ | ||
const filePath = path.resolve('/tmp/file,with,comma.txt'); | ||
const { status, stdout, stderr } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', | ||
'--allow-fs-read=*', | ||
`--allow-fs-write=${filePath}`, | ||
'-e', | ||
`console.log(process.permission.has("fs")); | ||
console.log(process.permission.has("fs.read")); | ||
console.log(process.permission.has("fs.write")); | ||
console.log(process.permission.has("fs.write", "/tmp/file,with,comma.txt"));`, | ||
] | ||
); | ||
const [fs, fsIn, fsOut, fsOutAllowed] = stdout.toString().split('\n'); | ||
assert.strictEqual(fs, 'false'); | ||
assert.strictEqual(fsIn, 'true'); | ||
assert.strictEqual(fsOut, 'false'); | ||
assert.strictEqual(fsOutAllowed, 'true'); | ||
assert.strictEqual(status, 0); | ||
assert.ok(stderr.toString().includes('Warning: The --allow-fs-write CLI flag has changed.')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.