mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
Some checks are pending
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Refs: https://github.com/nodejs/node/issues/48534 PR-URL: https://github.com/nodejs/node/pull/59711 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const {
|
|
ObjectFreeze,
|
|
} = primordials;
|
|
|
|
const permission = internalBinding('permission');
|
|
const { validateString, validateBuffer } = require('internal/validators');
|
|
const { Buffer } = require('buffer');
|
|
const { isBuffer } = Buffer;
|
|
|
|
let _permission;
|
|
|
|
module.exports = ObjectFreeze({
|
|
__proto__: null,
|
|
isEnabled() {
|
|
if (_permission === undefined) {
|
|
const { getOptionValue } = require('internal/options');
|
|
_permission = getOptionValue('--permission');
|
|
}
|
|
return _permission;
|
|
},
|
|
has(scope, reference) {
|
|
validateString(scope, 'scope');
|
|
if (reference != null) {
|
|
// TODO: add support for WHATWG URLs and Uint8Arrays.
|
|
if (isBuffer(reference)) {
|
|
validateBuffer(reference, 'reference');
|
|
} else {
|
|
validateString(reference, 'reference');
|
|
}
|
|
}
|
|
|
|
return permission.has(scope, reference);
|
|
},
|
|
availableFlags() {
|
|
return [
|
|
'--allow-fs-read',
|
|
'--allow-fs-write',
|
|
'--allow-addons',
|
|
'--allow-child-process',
|
|
'--allow-net',
|
|
'--allow-inspector',
|
|
'--allow-wasi',
|
|
'--allow-worker',
|
|
];
|
|
},
|
|
});
|