Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Node.js executor for DMOJ #1143

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions dmoj/executors/NODEJS.py
Original file line number Diff line number Diff line change
@@ -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', 'pkey_alloc']
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']
Loading