FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

permission: enforce addon permission in GetLinkedBinding · nodejs/node@ac3c412 · GitHub

/ node Public

Commit ac3c412

Browse files
authored andcommitted
permission: enforce addon permission in GetLinkedBinding
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #65432 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c2c31d6 commit ac3c412

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎src/node_binding.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,9 @@ void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
671671

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

676679
// Iterate from here to the nearest non-Worker Environment to see if there's
Lines 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+
}));
Lines 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)

Back | FazBrowse Home | New Git URL