Sign inSign up

fderepas/tal-node

By fderepas

Updated about 6 hours ago

Container for the NodeJs language to safely run arbitrary code.

Image
0

10K+

fderepas/tal-node repository overview

This docker enables to execute a source code for a JavaScript program in try_all_languages. NodeJs is the implementation used. Here is how the docker is meant to be used:

    +----- docker -----+
    | execute arbitrary|
    |    program       |
    +-/mnt/in--/mnt/out+
        |         |
      dir1      dir2   

There is one input directory on the host machine holding the source to execute and standard input for each execution.

The docker compiles the source code. Then executes the program for each standard input in dir1. Each corresponding output is written in dir2.

Here is a typical usage to launch two executions of prog.js with standard input input0.txt and input1.txt which will produce associated standard output, standard error, and return codes. For execution 0 files out0.txt, err0.txt, and errcode0.txt are created, for execution 1 files out1.txt, err1.txt, and errcode1.txt are created. For instance associated command line to launch docker with current directory for input and output is:

docker run \
       --mount type=bind,source=`pwd`,target=/mnt/in,ro \
       --mount type=bind,source=`pwd`,target=/mnt/out \
       --network none \
       --name tal-node-$$ --rm \
       tal-node:latest /bin/sh /home/tal/launch.sh 2

Since there is no stdin in Javascript a function named "prompt" enables to access the input line by line as seen in the launch script.

console.log(prompt()); // outputs first line from stdin
console.log(prompt()); // outputs second line from stdin

Tag summary

Content type

Image

Digest

sha256:072075c05

Size

158.4 MB

Last updated

about 6 hours ago

docker pull fderepas/tal-node