mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

Move permission model from 1.1 (Active Development) to 2.0 (Stable). PR-URL: https://github.com/nodejs/node/pull/56201 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
// Flags: --permission --allow-fs-read=* --allow-fs-write=* --allow-child-process
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
common.skipIfWorker();
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('no crypto');
|
|
}
|
|
|
|
const assert = require('assert');
|
|
const fixtures = require('../common/fixtures');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { spawnSync } = require('child_process');
|
|
const path = require('path');
|
|
|
|
const blockedFile = fixtures.path('permission', 'deny', 'protected-file.md');
|
|
const blockedFolder = tmpdir.path;
|
|
const file = fixtures.path('permission', 'fs-read.js');
|
|
const commonPathWildcard = path.join(__filename, '../../common*');
|
|
const commonPath = path.join(__filename, '../../common');
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
}
|
|
|
|
{
|
|
const { status, stderr } = spawnSync(
|
|
process.execPath,
|
|
[
|
|
'--permission', `--allow-fs-read=${file}`, `--allow-fs-read=${commonPathWildcard}`, file,
|
|
],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
BLOCKEDFILE: blockedFile,
|
|
BLOCKEDFOLDER: blockedFolder,
|
|
ALLOWEDFOLDER: commonPath,
|
|
},
|
|
}
|
|
);
|
|
assert.strictEqual(status, 0, stderr.toString());
|
|
}
|
|
|
|
{
|
|
tmpdir.refresh();
|
|
}
|