node/test/parallel/test-process-execve-permission-fail.js
Rafael Gonzaga b04c4a44a5
src: pass resource on permission checks for spawn
This commit enhances the permission model errors
when no --allow-child-process is used and the error
is emitted.

Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/58758
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-06-21 14:40:10 +00:00

21 lines
717 B
JavaScript

// Flags: --permission --allow-fs-read=*
'use strict';
const { mustCall, skip, isWindows, isIBMi } = require('../common');
const { fail, throws } = require('assert');
const { isMainThread } = require('worker_threads');
if (!isMainThread) {
skip('process.execve is not available in Workers');
} else if (isWindows || isIBMi) {
skip('process.execve is not available in Windows or IBM i');
}
if (process.argv[2] === 'replaced') {
fail('process.execve should not have been allowed.');
} else {
throws(mustCall(() => {
process.execve(process.execPath, [process.execPath, __filename, 'replaced'], process.env);
}), { code: 'ERR_ACCESS_DENIED', permission: 'ChildProcess', resource: process.execPath });
}