mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
413c16e490
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: https://github.com/nodejs/security-wg/issues/1039 PR-URL: https://github.com/nodejs/node/pull/49047 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
common.skipIfWorker();
|
|
if (!common.hasCrypto)
|
|
common.skip('no crypto');
|
|
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const { spawnSync } = require('child_process');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const blockedFolder = fixtures.path('permission', 'deny', 'protected-folder');
|
|
const blockedFile = fixtures.path('permission', 'deny', 'protected-file.md');
|
|
const relativeProtectedFile = './test/fixtures/permission/deny/protected-file.md';
|
|
const relativeProtectedFolder = './test/fixtures/permission/deny/protected-folder';
|
|
|
|
const commonPath = path.join(__filename, '../../common');
|
|
const regularFile = fixtures.path('permission', 'deny', 'regular-file.md');
|
|
const file = fixtures.path('permission', 'fs-write.js');
|
|
|
|
{
|
|
const { status, stderr } = spawnSync(
|
|
process.execPath,
|
|
[
|
|
'--experimental-permission',
|
|
'--allow-fs-read=*',
|
|
`--allow-fs-write=${regularFile}`, `--allow-fs-write=${commonPath}`,
|
|
file,
|
|
],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
BLOCKEDFILE: blockedFile,
|
|
BLOCKEDFOLDER: blockedFolder,
|
|
RELATIVEBLOCKEDFOLDER: relativeProtectedFolder,
|
|
RELATIVEBLOCKEDFILE: relativeProtectedFile,
|
|
ALLOWEDFILE: regularFile,
|
|
ALLOWEDFOLDER: commonPath,
|
|
},
|
|
}
|
|
);
|
|
assert.strictEqual(status, 0, stderr.toString());
|
|
}
|