0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 20:29:23 +01:00
nodejs/test/parallel/test-permission-fs-relative-path.js
Rafael Gonzaga 338a5be272
lib,src,permission: port path.resolve to C++
Co-Authored-By: Carlos Espa <cespatorres@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/50758
Refs: https://github.com/nodejs/security-wg/issues/898
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Claudio Wunder <cwunder@gnome.org>
2023-12-30 13:46:27 +00:00

31 lines
848 B
JavaScript

// Flags: --experimental-permission --allow-fs-read=* --allow-child-process
'use strict';
const common = require('../common');
common.skipIfWorker();
const assert = require('assert');
const { spawnSync } = require('child_process');
{
// Relative path as CLI args are supported
const { status, stdout } = spawnSync(
process.execPath,
[
'--experimental-permission',
'--allow-fs-read', '*',
'--allow-fs-write', '../fixtures/permission/deny/regular-file.md',
'-e',
`
const path = require("path");
const absolutePath = path.resolve("../fixtures/permission/deny/regular-file.md");
console.log(process.permission.has("fs.write", absolutePath));
`,
]
);
const [fsWrite] = stdout.toString().split('\n');
assert.strictEqual(fsWrite, 'true');
assert.strictEqual(status, 0);
}