forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
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: nodejs#49047 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Marco Ippolito <[email protected]>
- Loading branch information
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.