Skip to content

Commit 7bfc8c0

Browse files
committed
executors/NODEJS: add Node.js executor
1 parent c70e803 commit 7bfc8c0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ The judge can also grade in the languages listed below:
6767
* Groovy
6868
* Haskell
6969
* INTERCAL
70+
* JavaScript (Node.js and V8)
7071
* Kotlin
7172
* Lean 4
7273
* LLVM IR

dmoj/executors/NODEJS.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from dmoj.cptbox.filesystem_policies import ExactFile
2+
from dmoj.executors.script_executor import ScriptExecutor
3+
4+
5+
class Executor(ScriptExecutor):
6+
ext = 'js'
7+
command = 'node'
8+
nproc = -1
9+
command_paths = ['node', 'nodejs']
10+
syscalls = ['capget', 'eventfd2', 'shutdown']
11+
address_grace = 1048576
12+
test_program = """
13+
process.stdin.on('readable', () => {
14+
const chunk = process.stdin.read();
15+
if (chunk != null) {
16+
process.stdout.write(chunk);
17+
}
18+
});
19+
"""
20+
21+
def get_env(self):
22+
env = super().get_env()
23+
# Disable io_uring due to potential security implications
24+
env['UV_USE_IO_URING'] = '0'
25+
return env
26+
27+
def get_fs(self):
28+
return super().get_fs() + [ExactFile('/usr/lib/ssl/openssl.cnf')]
29+
30+
@classmethod
31+
def get_version_flags(cls, command):
32+
return ['--version']

0 commit comments

Comments
 (0)