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
- Loading branch information
Showing
22 changed files
with
149 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
'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 res = stdout.toString(); | ||
const [fs, fsIn, fsOut, fsOutAllowed] = res.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 recently 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
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