test: --force-context-aware cli flag
PR-URL: https://github.com/nodejs/node/pull/29631 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
3c17f160e3
commit
f120e6d817
@ -416,7 +416,7 @@ Silence all process warnings (including deprecations).
|
||||
added: REPLACEME
|
||||
-->
|
||||
|
||||
Disable loading non-context-aware native addons.
|
||||
Disable loading native addons that are not [context-aware][].
|
||||
|
||||
### `--openssl-config=file`
|
||||
<!-- YAML
|
||||
@ -1264,3 +1264,4 @@ greater than `4` (its current default value). For more information, see the
|
||||
[experimental ECMAScript Module]: esm.html#esm_resolve_hook
|
||||
[libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html
|
||||
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
|
||||
[context-aware]: addons.html#addons_context_aware_addons
|
||||
|
6
test/addons/force-context-aware/binding.cc
Normal file
6
test/addons/force-context-aware/binding.cc
Normal file
@ -0,0 +1,6 @@
|
||||
#include <node.h>
|
||||
#include <v8.h>
|
||||
|
||||
void init(v8::Local<v8::Object> exports) {}
|
||||
|
||||
NODE_MODULE(NODE_GYP_MODULE_NAME, init)
|
9
test/addons/force-context-aware/binding.gyp
Normal file
9
test/addons/force-context-aware/binding.gyp
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'binding',
|
||||
'sources': [ 'binding.cc' ],
|
||||
'includes': ['../common.gypi'],
|
||||
}
|
||||
]
|
||||
}
|
4
test/addons/force-context-aware/index.js
Normal file
4
test/addons/force-context-aware/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
const common = require('../../common');
|
||||
|
||||
require(`./build/${common.buildType}/binding`);
|
13
test/addons/force-context-aware/test.js
Normal file
13
test/addons/force-context-aware/test.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
const common = require('../../common');
|
||||
const childProcess = require('child_process');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
|
||||
const mod = path.join('test', 'addons', 'force-context-aware', 'index.js');
|
||||
|
||||
const execString = `"${process.execPath}" --force-context-aware ./${mod}`;
|
||||
childProcess.exec(execString, common.mustCall((err) => {
|
||||
const errMsg = 'Loading non context-aware native modules has been disabled';
|
||||
assert.strictEqual(err.message.includes(errMsg), true);
|
||||
}));
|
@ -1,3 +1,5 @@
|
||||
// Flags: --force-context-aware
|
||||
|
||||
'use strict';
|
||||
|
||||
const common = require('../../common');
|
||||
|
Loading…
x
Reference in New Issue
Block a user