From 7bfc8c0a6052c9bd57dedff557d97a5ae0d69131 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Fri, 8 Dec 2023 12:13:16 -0800 Subject: [PATCH] executors/NODEJS: add Node.js executor --- README.md | 1 + dmoj/executors/NODEJS.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 dmoj/executors/NODEJS.py diff --git a/README.md b/README.md index 8e6e30615..daddcb1c7 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ The judge can also grade in the languages listed below: * Groovy * Haskell * INTERCAL +* JavaScript (Node.js and V8) * Kotlin * Lean 4 * LLVM IR diff --git a/dmoj/executors/NODEJS.py b/dmoj/executors/NODEJS.py new file mode 100644 index 000000000..e8db77ab6 --- /dev/null +++ b/dmoj/executors/NODEJS.py @@ -0,0 +1,32 @@ +from dmoj.cptbox.filesystem_policies import ExactFile +from dmoj.executors.script_executor import ScriptExecutor + + +class Executor(ScriptExecutor): + ext = 'js' + command = 'node' + nproc = -1 + command_paths = ['node', 'nodejs'] + syscalls = ['capget', 'eventfd2', 'shutdown'] + address_grace = 1048576 + test_program = """ +process.stdin.on('readable', () => { + const chunk = process.stdin.read(); + if (chunk != null) { + process.stdout.write(chunk); + } +}); +""" + + def get_env(self): + env = super().get_env() + # Disable io_uring due to potential security implications + env['UV_USE_IO_URING'] = '0' + return env + + def get_fs(self): + return super().get_fs() + [ExactFile('/usr/lib/ssl/openssl.cnf')] + + @classmethod + def get_version_flags(cls, command): + return ['--version']