mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
permission: enforce addon permission in GetLinkedBinding
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/65432 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
214cf0693b
commit
46a7dbd2d0
3 files changed
+37
No files matched your search
@@ -672,6 +672,9 @@ void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
node::Utf8Value module_name_v(env->isolate(), module_name);
|
||||
const char* name = *module_name_v;
|
||||
THROW_IF_INSUFFICIENT_PERMISSIONS(
|
||||
env, permission::PermissionScope::kAddon, module_name_v.ToStringView());
|
||||
|
||||
node_module* mod = nullptr;
|
||||
|
||||
// Iterate from here to the nearest non-Worker Environment to see if there's
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Flags: --permission --allow-addons --allow-fs-read=*
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('node:assert');
|
||||
|
||||
assert.strictEqual(process.permission.has('addon'), true);
|
||||
|
||||
process.permission.drop('addon');
|
||||
|
||||
assert.strictEqual(process.permission.has('addon'), false);
|
||||
|
||||
assert.throws(() => {
|
||||
process._linkedBinding('missing');
|
||||
}, common.expectsError({
|
||||
code: 'ERR_ACCESS_DENIED',
|
||||
permission: 'Addon',
|
||||
resource: 'missing',
|
||||
}));
|
||||
@@ -0,0 +1,15 @@
|
||||
// Flags: --permission --allow-fs-read=*
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('node:assert');
|
||||
|
||||
assert.strictEqual(process.permission.has('addon'), false);
|
||||
|
||||
assert.throws(() => {
|
||||
process._linkedBinding('missing');
|
||||
}, common.expectsError({
|
||||
code: 'ERR_ACCESS_DENIED',
|
||||
permission: 'Addon',
|
||||
resource: 'missing',
|
||||
}));
|
||||
Reference in new issue
Block a user