GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — permission: enforce addon permission in GetLinkedBinding · nodejs/node@2cfc441

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_binding.cc
  • test/parallel
    • test-permission-linked-binding-drop.js
    • test-permission-linked-binding.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_binding.cc‎

Copy file name to clipboardExpand all lines: src/node_binding.cc
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@ void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
670670

671671
node::Utf8Value module_name_v(env->isolate(), module_name);
672672
const char* name = *module_name_v;
673+
THROW_IF_INSUFFICIENT_PERMISSIONS(
674+
env, permission::PermissionScope::kAddon, module_name_v.ToStringView());
675+
673676
node_module* mod = nullptr;
674677

675678
// Iterate from here to the nearest non-Worker Environment to see if there's
Collapse file

‎test/parallel/test-permission-linked-binding-drop.js‎

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Flags: --permission --allow-addons --allow-fs-read=*
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('node:assert');
6+
7+
assert.strictEqual(process.permission.has('addon'), true);
8+
9+
process.permission.drop('addon');
10+
11+
assert.strictEqual(process.permission.has('addon'), false);
12+
13+
assert.throws(() => {
14+
process._linkedBinding('missing');
15+
}, common.expectsError({
16+
code: 'ERR_ACCESS_DENIED',
17+
permission: 'Addon',
18+
resource: 'missing',
19+
}));
Collapse file

‎test/parallel/test-permission-linked-binding.js‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Flags: --permission --allow-fs-read=*
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('node:assert');
6+
7+
assert.strictEqual(process.permission.has('addon'), false);
8+
9+
assert.throws(() => {
10+
process._linkedBinding('missing');
11+
}, common.expectsError({
12+
code: 'ERR_ACCESS_DENIED',
13+
permission: 'Addon',
14+
resource: 'missing',
15+
}));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.