From 37946d8542f95c51d20a8d6c601d04815b3f19ab Mon Sep 17 00:00:00 2001 From: vcokltfre Date: Fri, 30 Apr 2021 09:10:26 +0100 Subject: [PATCH 1/7] fix: add yeethon to supported languages list (#240) --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 38bad62..f1d0f2e 100644 --- a/readme.md +++ b/readme.md @@ -315,6 +315,7 @@ Content-Type: application/json `swift`, `typescript`, `vlang`, +`yeethon`, `zig`,
From f2973f0536feac668f291077e64a789db3f928bd Mon Sep 17 00:00:00 2001 From: Dan Vargas <10914883+dvargas46@users.noreply.github.com> Date: Fri, 30 Apr 2021 06:33:29 -0500 Subject: [PATCH 2/7] pkg(ruby-3.0.1): add ruby 3.0.1 (#242) Co-authored-by: Vargas, Dan --- packages/ruby/3.0.1/build.sh | 21 +++++++++++++++++++++ packages/ruby/3.0.1/environment | 4 ++++ packages/ruby/3.0.1/metadata.json | 5 +++++ packages/ruby/3.0.1/run | 4 ++++ packages/ruby/3.0.1/test.rb | 1 + 5 files changed, 35 insertions(+) create mode 100755 packages/ruby/3.0.1/build.sh create mode 100644 packages/ruby/3.0.1/environment create mode 100644 packages/ruby/3.0.1/metadata.json create mode 100644 packages/ruby/3.0.1/run create mode 100644 packages/ruby/3.0.1/test.rb diff --git a/packages/ruby/3.0.1/build.sh b/packages/ruby/3.0.1/build.sh new file mode 100755 index 0000000..ab6b8a0 --- /dev/null +++ b/packages/ruby/3.0.1/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build +cd build + +# Download and extract ruby +curl "https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.1.tar.gz" -o ruby.tar.gz +tar xzf ruby.tar.gz --strip-components=1 +rm ruby.tar.gz + +# Autoconf based +./configure --prefix "$PREFIX" +make -j$(nproc) +make install -j$(nproc) + +# Cleanup +cd .. +rm -rf build + diff --git a/packages/ruby/3.0.1/environment b/packages/ruby/3.0.1/environment new file mode 100644 index 0000000..118cf33 --- /dev/null +++ b/packages/ruby/3.0.1/environment @@ -0,0 +1,4 @@ +#!/bin/bash + +# Path to ruby binary +export PATH=$PWD/bin:$PATH diff --git a/packages/ruby/3.0.1/metadata.json b/packages/ruby/3.0.1/metadata.json new file mode 100644 index 0000000..283cf71 --- /dev/null +++ b/packages/ruby/3.0.1/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "ruby", + "version": "3.0.1", + "aliases": ["ruby3", "rb"] +} diff --git a/packages/ruby/3.0.1/run b/packages/ruby/3.0.1/run new file mode 100644 index 0000000..55cca9c --- /dev/null +++ b/packages/ruby/3.0.1/run @@ -0,0 +1,4 @@ +#!/bin/bash + +# Run ruby script with args +ruby "$@" diff --git a/packages/ruby/3.0.1/test.rb b/packages/ruby/3.0.1/test.rb new file mode 100644 index 0000000..eb08579 --- /dev/null +++ b/packages/ruby/3.0.1/test.rb @@ -0,0 +1 @@ +puts("OK") From a49acc7dbe4d63090250d6a1d1536542e362aef3 Mon Sep 17 00:00:00 2001 From: Felix <41747605+Defelo@users.noreply.github.com> Date: Sat, 1 May 2021 11:10:53 +0200 Subject: [PATCH 3/7] Added max_memory_usage parameter (#238) * Added max_memory_usage parameter * Added max_memory_usage description to readme --- api/src/api/v2.js | 21 +++++++++++++++++++-- api/src/config.js | 6 ++++++ api/src/job.js | 12 ++++++++---- readme.md | 4 +++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 72db74e..4d8713a 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -1,13 +1,14 @@ const express = require('express'); const router = express.Router(); +const config = require('../config'); const runtime = require('../runtime'); const {Job} = require("../job"); const package = require('../package') const logger = require('logplease').create('api/v1'); router.post('/execute', async function(req, res){ - const {language, version, files, stdin, args, run_timeout, compile_timeout} = req.body; + const {language, version, files, stdin, args, run_timeout, compile_timeout, max_memory_usage} = req.body; if(!language || typeof language !== "string") { @@ -46,6 +47,21 @@ router.post('/execute', async function(req, res){ } } + if (max_memory_usage) { + if (typeof max_memory_usage !== "number" || max_memory_usage < 0) { + return res + .status(400) + .send({ + message: "if specified, max_memory_usage must be a non-negative number" + }) + } else if (max_memory_usage > config.max_memory_usage) { + return res + .status(400) + .send({ + message: "max_memory_usage cannot exceed the configured limit of " + config.max_memory_usage + }) + } + } @@ -68,7 +84,8 @@ router.post('/execute', async function(req, res){ timeouts: { run: run_timeout || 3000, compile: compile_timeout || 10000 - } + }, + max_memory_usage: max_memory_usage || config.max_memory_usage }); await job.prime(); diff --git a/api/src/config.js b/api/src/config.js index c97b64c..12da1c6 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -108,6 +108,12 @@ const options = [ default: 1000000, //1MB validators: [] }, + { + key: 'max_memory_usage', + desc: 'Max memory usage in bytes', + default: 256000000, //256MB + validators: [] + }, { key: 'repo_url', desc: 'URL of repo index', diff --git a/api/src/job.js b/api/src/job.js index b711ac1..258300a 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -19,7 +19,7 @@ let gid = 0; class Job { - constructor({ runtime, files, args, stdin, timeouts }) { + constructor({ runtime, files, args, stdin, timeouts, max_memory_usage }) { this.uuid = uuidv4(); this.runtime = runtime; this.files = files.map((file,i) => ({ @@ -30,6 +30,7 @@ class Job { this.args = args; this.stdin = stdin; this.timeouts = timeouts; + this.max_memory_usage = max_memory_usage; this.uid = config.runner_uid_min + uid; this.gid = config.runner_gid_min + gid; @@ -75,7 +76,8 @@ class Job { 'prlimit', '--nproc=' + config.max_process_count, '--nofile=' + config.max_open_files, - '--fsize=' + config.max_file_size + '--fsize=' + config.max_file_size, + '--as=' + this.max_memory_usage ]; const proc_call = [ @@ -161,7 +163,8 @@ class Job { compile = await this.safe_call( path.join(this.runtime.pkgdir, 'compile'), this.files.map(x => x.name), - this.timeouts.compile + this.timeouts.compile, + config.max_memory_usage ); } @@ -170,7 +173,8 @@ class Job { const run = await this.safe_call( path.join(this.runtime.pkgdir, 'run'), [this.files[0].name, ...this.args], - this.timeouts.run + this.timeouts.run, + this.max_memory_usage ); this.state = job_states.EXECUTED; diff --git a/readme.md b/readme.md index f1d0f2e..21d152d 100644 --- a/readme.md +++ b/readme.md @@ -210,6 +210,7 @@ This endpoint requests execution of some arbitrary code. - `args` (*optional*) The arguments to pass to the program. Must be an array or left out. Defaults to `[]`. - `compile_timeout` (*optional*) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to `10000` (10 seconds). - `run_timeout` (*optional*) The maximum time allowed for the run stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to `3000` (3 seconds). +- `max_memory_usage` (*optional*) The maximum amount of memory the run stage is allowed to use. Must be a number or left out. Defaults to `256000000` (256 MB) ```json { @@ -228,7 +229,8 @@ This endpoint requests execution of some arbitrary code. "3" ], "compile_timeout": 10000, - "run_timeout": 3000 + "run_timeout": 3000, + "max_memory_usage": 256000000 } ``` A typical response upon successful execution will contain 1 or 2 keys `run` and `compile`. From 2412d50f82def5c7f1ddc8150aa22992db7209a2 Mon Sep 17 00:00:00 2001 From: Dan Vargas <10914883+dvargas46@users.noreply.github.com> Date: Sat, 1 May 2021 21:41:53 -0500 Subject: [PATCH 4/7] pkg(octave-6.2.0): add deps for octave (#245) --- api/Dockerfile | 5 ++++- repo/Dockerfile | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 7388afa..686ff02 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -10,7 +10,10 @@ RUN for i in $(seq 1001 1500); do \ RUN apt-get update && \ apt-get install -y libxml2 gnupg tar coreutils util-linux libc6-dev \ binutils build-essential locales libpcre3-dev libevent-dev libgmp3-dev \ - libncurses6 libncurses5 libedit-dev libseccomp-dev rename procps python3 && \ + libncurses6 libncurses5 libedit-dev libseccomp-dev rename procps python3 \ + libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev \ + libfftw3-dev libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev \ + libsundials-dev && \ rm -rf /var/lib/apt/lists/* RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen diff --git a/repo/Dockerfile b/repo/Dockerfile index fb4a315..53d6388 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -6,8 +6,9 @@ RUN apt-get update && apt-get install -y unzip autoconf build-essential libssl-d linux-headers-amd64 perl xz-utils python3 python3-pip gnupg jq zlib1g-dev \ cmake cmake-doc extra-cmake-modules build-essential gcc binutils bash coreutils \ util-linux pciutils usbutils coreutils binutils findutils grep libncurses5-dev \ - libncursesw5-dev python3-pip libgmp-dev libmpfr-dev python2 libffi-dev \ - libreadline-dev && \ + libncursesw5-dev python3-pip libgmp-dev libmpfr-dev python2 libffi-dev gfortran\ + libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev libfftw3-dev \ + libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev libsundials-dev && \ ln -sf /bin/bash /bin/sh && \ rm -rf /var/lib/apt/lists/* && \ update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2 From d577072749b1c8f57d3eb050a7a81cd6ab342b11 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 2 May 2021 14:55:37 +1200 Subject: [PATCH 6/7] Revert "Added max_memory_usage parameter (#238)" (#246) This reverts commit a49acc7dbe4d63090250d6a1d1536542e362aef3. --- api/src/api/v2.js | 21 ++------------------- api/src/config.js | 6 ------ api/src/job.js | 12 ++++-------- readme.md | 4 +--- 4 files changed, 7 insertions(+), 36 deletions(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 4d8713a..72db74e 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -1,14 +1,13 @@ const express = require('express'); const router = express.Router(); -const config = require('../config'); const runtime = require('../runtime'); const {Job} = require("../job"); const package = require('../package') const logger = require('logplease').create('api/v1'); router.post('/execute', async function(req, res){ - const {language, version, files, stdin, args, run_timeout, compile_timeout, max_memory_usage} = req.body; + const {language, version, files, stdin, args, run_timeout, compile_timeout} = req.body; if(!language || typeof language !== "string") { @@ -47,21 +46,6 @@ router.post('/execute', async function(req, res){ } } - if (max_memory_usage) { - if (typeof max_memory_usage !== "number" || max_memory_usage < 0) { - return res - .status(400) - .send({ - message: "if specified, max_memory_usage must be a non-negative number" - }) - } else if (max_memory_usage > config.max_memory_usage) { - return res - .status(400) - .send({ - message: "max_memory_usage cannot exceed the configured limit of " + config.max_memory_usage - }) - } - } @@ -84,8 +68,7 @@ router.post('/execute', async function(req, res){ timeouts: { run: run_timeout || 3000, compile: compile_timeout || 10000 - }, - max_memory_usage: max_memory_usage || config.max_memory_usage + } }); await job.prime(); diff --git a/api/src/config.js b/api/src/config.js index 12da1c6..c97b64c 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -108,12 +108,6 @@ const options = [ default: 1000000, //1MB validators: [] }, - { - key: 'max_memory_usage', - desc: 'Max memory usage in bytes', - default: 256000000, //256MB - validators: [] - }, { key: 'repo_url', desc: 'URL of repo index', diff --git a/api/src/job.js b/api/src/job.js index 258300a..b711ac1 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -19,7 +19,7 @@ let gid = 0; class Job { - constructor({ runtime, files, args, stdin, timeouts, max_memory_usage }) { + constructor({ runtime, files, args, stdin, timeouts }) { this.uuid = uuidv4(); this.runtime = runtime; this.files = files.map((file,i) => ({ @@ -30,7 +30,6 @@ class Job { this.args = args; this.stdin = stdin; this.timeouts = timeouts; - this.max_memory_usage = max_memory_usage; this.uid = config.runner_uid_min + uid; this.gid = config.runner_gid_min + gid; @@ -76,8 +75,7 @@ class Job { 'prlimit', '--nproc=' + config.max_process_count, '--nofile=' + config.max_open_files, - '--fsize=' + config.max_file_size, - '--as=' + this.max_memory_usage + '--fsize=' + config.max_file_size ]; const proc_call = [ @@ -163,8 +161,7 @@ class Job { compile = await this.safe_call( path.join(this.runtime.pkgdir, 'compile'), this.files.map(x => x.name), - this.timeouts.compile, - config.max_memory_usage + this.timeouts.compile ); } @@ -173,8 +170,7 @@ class Job { const run = await this.safe_call( path.join(this.runtime.pkgdir, 'run'), [this.files[0].name, ...this.args], - this.timeouts.run, - this.max_memory_usage + this.timeouts.run ); this.state = job_states.EXECUTED; diff --git a/readme.md b/readme.md index 21d152d..f1d0f2e 100644 --- a/readme.md +++ b/readme.md @@ -210,7 +210,6 @@ This endpoint requests execution of some arbitrary code. - `args` (*optional*) The arguments to pass to the program. Must be an array or left out. Defaults to `[]`. - `compile_timeout` (*optional*) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to `10000` (10 seconds). - `run_timeout` (*optional*) The maximum time allowed for the run stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to `3000` (3 seconds). -- `max_memory_usage` (*optional*) The maximum amount of memory the run stage is allowed to use. Must be a number or left out. Defaults to `256000000` (256 MB) ```json { @@ -229,8 +228,7 @@ This endpoint requests execution of some arbitrary code. "3" ], "compile_timeout": 10000, - "run_timeout": 3000, - "max_memory_usage": 256000000 + "run_timeout": 3000 } ``` A typical response upon successful execution will contain 1 or 2 keys `run` and `compile`. From d55d158fb67a97e0ad8887247a06d712fd6b6a91 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 2 May 2021 15:21:54 +1200 Subject: [PATCH 7/7] bump repo ci --- repo/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/repo/Dockerfile b/repo/Dockerfile index 53d6388..106fef4 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -17,3 +17,4 @@ ADD entrypoint.sh mkindex.sh / ENTRYPOINT ["bash","/entrypoint.sh"] CMD ["--no-build"] +