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 — lib,permission: fix addon permission drop · nodejs/node@92a3dc3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_binding.cc
  • test/parallel
    • test-permission-drop-addons.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
@@ -5,6 +5,7 @@
55
#include "node_errors.h"
66
#include "node_external_reference.h"
77
#include "node_url_pattern.h"
8+
#include "permission/permission.h"
89
#include "util.h"
910

1011
#include <string>
@@ -449,6 +450,8 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
449450
return THROW_ERR_DLOPEN_DISABLED(
450451
env, "Cannot load native addon because loading addons is disabled.");
451452
}
453+
THROW_IF_INSUFFICIENT_PERMISSIONS(
454+
env, permission::PermissionScope::kAddon, "");
452455

453456
auto context = env->context();
454457

Collapse file

‎test/parallel/test-permission-drop-addons.js‎

Copy file name to clipboard
+38Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Flags: --permission --allow-addons --allow-fs-read=*
2+
'use strict';
3+
4+
const common = require('../common');
5+
const { isMainThread } = require('worker_threads');
6+
7+
if (!isMainThread) {
8+
common.skip('This test only works on a main thread');
9+
}
10+
11+
const assert = require('assert');
12+
13+
let bindingPath;
14+
try {
15+
bindingPath = require.resolve(
16+
`../addons/hello-world/build/${common.buildType}/binding`);
17+
} catch (err) {
18+
if (err.code !== 'MODULE_NOT_FOUND') {
19+
throw err;
20+
}
21+
common.skip('addon not found');
22+
}
23+
24+
function openAddon() {
25+
process.dlopen({ exports: {} }, bindingPath);
26+
}
27+
28+
assert.ok(process.permission.has('addon'));
29+
openAddon();
30+
31+
process.permission.drop('addon');
32+
assert.ok(!process.permission.has('addon'));
33+
assert.throws(() => {
34+
openAddon();
35+
}, common.expectsError({
36+
code: 'ERR_ACCESS_DENIED',
37+
permission: 'Addon',
38+
}));

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.