Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/node_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/parallel/test-permission-linked-binding-drop.js
Original file line number Diff line number Diff line change
@@ -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',
}));
15 changes: 15 additions & 0 deletions test/parallel/test-permission-linked-binding.js
Original file line number Diff line number Diff line change
@@ -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',
}));
Loading