diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-06-27 00:13:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-27 00:13:18 +0200 |
commit | e4ecb70d0810a41f6ad7e33365d29b00bde721a3 (patch) | |
tree | 0706abe3e3b3b734b66571bf4ff85bbdd2e545a1 | |
parent | 5b47e4dc3858285b0d8fe95f0e7c197edca782e8 (diff) | |
parent | 413b313ad2cfd5a1ee32369b944436e14fc8bfb3 (diff) | |
download | rneovim-e4ecb70d0810a41f6ad7e33365d29b00bde721a3.tar.gz rneovim-e4ecb70d0810a41f6ad7e33365d29b00bde721a3.tar.bz2 rneovim-e4ecb70d0810a41f6ad7e33365d29b00bde721a3.zip |
Merge #10345 from bfredl/apisandbox-0.3
eval/api: don't allow the API to be called in the sandbox.
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | test/functional/eval/api_functions_spec.lua | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9163673a32..618cd50a78 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6516,6 +6516,10 @@ static void float_op_wrapper(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void api_wrapper(typval_T *argvars, typval_T *rettv, FunPtr fptr) { + if (check_restricted() || check_secure()) { + return; + } + ApiDispatchWrapper fn = (ApiDispatchWrapper)fptr; Array args = ARRAY_DICT_INIT; diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index 6f440c7d82..951c5d6854 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -4,7 +4,8 @@ local lfs = require('lfs') local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear, curbufmeths = helpers.clear, helpers.curbufmeths local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval -local insert = helpers.insert +local insert, meth_pcall = helpers.insert, helpers.meth_pcall +local meths = helpers.meths describe('api functions', function() before_each(clear) @@ -145,4 +146,10 @@ describe('api functions', function() ]]) screen:detach() end) + + it('cannot be called from sandbox', function() + eq({false, 'Vim(call):E48: Not allowed in sandbox'}, + meth_pcall(command, "sandbox call nvim_input('ievil')")) + eq({''}, meths.buf_get_lines(0, 0, -1, true)) + end) end) |