mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	eval/api: don't allow the API to be called in the sandbox.
Identifying and maintaining a "secure" subset of the API would be too much busywork. So just disable the entire thing.
This commit is contained in:
		| @@ -6669,6 +6669,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) | static void api_wrapper(typval_T *argvars, typval_T *rettv, FunPtr fptr) | ||||||
| { | { | ||||||
|  |   if (check_restricted() || check_secure()) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   ApiDispatchWrapper fn = (ApiDispatchWrapper)fptr; |   ApiDispatchWrapper fn = (ApiDispatchWrapper)fptr; | ||||||
|  |  | ||||||
|   Array args = ARRAY_DICT_INIT; |   Array args = ARRAY_DICT_INIT; | ||||||
|   | |||||||
| @@ -4,7 +4,8 @@ local lfs = require('lfs') | |||||||
| local neq, eq, command = helpers.neq, helpers.eq, helpers.command | local neq, eq, command = helpers.neq, helpers.eq, helpers.command | ||||||
| local clear, curbufmeths = helpers.clear, helpers.curbufmeths | local clear, curbufmeths = helpers.clear, helpers.curbufmeths | ||||||
| local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval | 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('eval-API', function() | describe('eval-API', function() | ||||||
|   before_each(clear) |   before_each(clear) | ||||||
| @@ -145,4 +146,10 @@ describe('eval-API', function() | |||||||
|     ]]) |     ]]) | ||||||
|     screen:detach() |     screen:detach() | ||||||
|   end) |   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) | end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Björn Linse
					Björn Linse