| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 059e47c commit 7705efd
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,6 +181,9 @@ void SetConsoleExtensionInstaller(const FunctionCallbackInfo<Value>& info) { | |||
| 181 | 181 | ||
| 182 | 182 | void CallAndPauseOnStart(const FunctionCallbackInfo<v8::Value>& args) { | |
| 183 | 183 | Environment* env = Environment::GetCurrent(args); | |
| 184 | + THROW_IF_INSUFFICIENT_PERMISSIONS(env, | ||
| 185 | + permission::PermissionScope::kInspector, | ||
| 186 | + "PauseOnNextJavascriptStatement"); | ||
| 184 | 187 | CHECK_GT(args.Length(), 1); | |
| 185 | 188 | CHECK(args[0]->IsFunction()); | |
| 186 | 189 | SlicedArguments call_args(args, /* start */ 2); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1082,6 +1082,21 @@ bool ContextifyScript::EvalMachine(Local<Context> context, | |||
| 1082 | 1082 | ||
| 1083 | 1083 | #if HAVE_INSPECTOR | |
| 1084 | 1084 | if (break_on_first_line) { | |
| 1085 | + if (UNLIKELY(!env->permission()->is_granted( | ||
| 1086 | + env, | ||
| 1087 | + permission::PermissionScope::kInspector, | ||
| 1088 | + "PauseOnNextJavascriptStatement"))) { | ||
| 1089 | + node::permission::Permission::ThrowAccessDenied( | ||
| 1090 | + env, | ||
| 1091 | + permission::PermissionScope::kInspector, | ||
| 1092 | + "PauseOnNextJavascriptStatement"); | ||
| 1093 | + if (display_errors) { | ||
| 1094 | + // We should decorate non-termination exceptions | ||
| 1095 | + errors::DecorateErrorStack(env, try_catch); | ||
| 1096 | + } | ||
| 1097 | + try_catch.ReThrow(); | ||
| 1098 | + return false; | ||
| 1099 | + } | ||
| 1085 | 1100 | env->inspector_agent()->PauseOnNextJavascriptStatement("Break on start"); | |
| 1086 | 1101 | } | |
| 1087 | 1102 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + console.log("Hi!") | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,41 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { spawnSync } = require('child_process'); | ||
| 6 | + const fixtures = require('../common/fixtures'); | ||
| 7 | + const file = fixtures.path('permission', 'inspector-brk.js'); | ||
| 8 | + | ||
| 9 | + common.skipIfWorker(); | ||
| 10 | + common.skipIfInspectorDisabled(); | ||
| 11 | + | ||
| 12 | + // See https://github.com/nodejs/node/issues/53385 | ||
| 13 | + { | ||
| 14 | + const { status, stderr } = spawnSync( | ||
| 15 | + process.execPath, | ||
| 16 | + [ | ||
| 17 | + '--experimental-permission', | ||
| 18 | + '--allow-fs-read=*', | ||
| 19 | + '--inspect-brk', | ||
| 20 | + file, | ||
| 21 | + ], | ||
| 22 | + ); | ||
| 23 | + | ||
| 24 | + assert.strictEqual(status, 1); | ||
| 25 | + assert.match(stderr.toString(), /Error: Access to this API has been restricted/); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + { | ||
| 29 | + const { status, stderr } = spawnSync( | ||
| 30 | + process.execPath, | ||
| 31 | + [ | ||
| 32 | + '--experimental-permission', | ||
| 33 | + '--inspect-brk', | ||
| 34 | + '--eval', | ||
| 35 | + 'console.log("Hi!")', | ||
| 36 | + ], | ||
| 37 | + ); | ||
| 38 | + | ||
| 39 | + assert.strictEqual(status, 1); | ||
| 40 | + assert.match(stderr.toString(), /Error: Access to this API has been restricted/); | ||
| 41 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments