mirror of
https://github.com/janet-lang/janet
synced 2026-10-04 23:01:41 +00:00
Add unmarshal sandbox.
This commit is contained in:
+3
-1
@@ -767,6 +767,7 @@ static const SandboxOption sandbox_options[] = {
|
|||||||
{"signal", JANET_SANDBOX_SIGNAL},
|
{"signal", JANET_SANDBOX_SIGNAL},
|
||||||
{"subprocess", JANET_SANDBOX_SUBPROCESS},
|
{"subprocess", JANET_SANDBOX_SUBPROCESS},
|
||||||
{"threads", JANET_SANDBOX_THREADS},
|
{"threads", JANET_SANDBOX_THREADS},
|
||||||
|
{"unmarshal", JANET_SANDBOX_UNMARSHAL},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -795,7 +796,8 @@ JANET_CORE_FN(janet_core_sandbox,
|
|||||||
"* :sandbox - disallow calling this function\n"
|
"* :sandbox - disallow calling this function\n"
|
||||||
"* :signal - disallow adding or removing signal handlers\n"
|
"* :signal - disallow adding or removing signal handlers\n"
|
||||||
"* :subprocess - disallow running subprocesses\n"
|
"* :subprocess - disallow running subprocesses\n"
|
||||||
"* :threads - disallow spawning threads with `ev/thread`. Certain helper threads may still be spawned.") {
|
"* :threads - disallow spawning threads with `ev/thread`. Certain helper threads may still be spawned.\n"
|
||||||
|
"* :unmarshal - disallow calling the unmarshal function.\n") {
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
for (int32_t i = 0; i < argc; i++) {
|
for (int32_t i = 0; i < argc; i++) {
|
||||||
JanetKeyword kw = janet_getkeyword(argv, i);
|
JanetKeyword kw = janet_getkeyword(argv, i);
|
||||||
|
|||||||
@@ -1698,6 +1698,7 @@ JANET_CORE_FN(cfun_unmarshal,
|
|||||||
"Unmarshal a value from a buffer. An optional lookup table "
|
"Unmarshal a value from a buffer. An optional lookup table "
|
||||||
"can be provided to allow for aliases to be resolved. Returns the value "
|
"can be provided to allow for aliases to be resolved. Returns the value "
|
||||||
"unmarshalled from the buffer.") {
|
"unmarshalled from the buffer.") {
|
||||||
|
janet_sandbox_assert(JANET_SANDBOX_UNMARSHAL);
|
||||||
janet_arity(argc, 1, 2);
|
janet_arity(argc, 1, 2);
|
||||||
JanetByteView view = janet_getbytes(argv, 0);
|
JanetByteView view = janet_getbytes(argv, 0);
|
||||||
JanetTable *reg = NULL;
|
JanetTable *reg = NULL;
|
||||||
|
|||||||
@@ -2008,6 +2008,7 @@ JANET_API void janet_stacktrace_ext(JanetFiber *fiber, Janet err, const char *pr
|
|||||||
#define JANET_SANDBOX_COMPILE 32768
|
#define JANET_SANDBOX_COMPILE 32768
|
||||||
#define JANET_SANDBOX_ASM 65536
|
#define JANET_SANDBOX_ASM 65536
|
||||||
#define JANET_SANDBOX_THREADS 131072
|
#define JANET_SANDBOX_THREADS 131072
|
||||||
|
#define JANET_SANDBOX_UNMARSHAL 262144
|
||||||
#define JANET_SANDBOX_ALL (UINT32_MAX)
|
#define JANET_SANDBOX_ALL (UINT32_MAX)
|
||||||
JANET_API void janet_sandbox(uint32_t flags);
|
JANET_API void janet_sandbox(uint32_t flags);
|
||||||
JANET_API void janet_sandbox_assert(uint32_t forbidden_flags);
|
JANET_API void janet_sandbox_assert(uint32_t forbidden_flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user