From 8833d4f4884ff5fe5c92dca2cea3f2ed09570e33 Mon Sep 17 00:00:00 2001 From: Brian Seymour Date: Thu, 8 Aug 2019 11:42:30 -0500 Subject: [PATCH] ts support --- api/main.go | 1 + lxc/execute | 3 +++ lxc/executors/typescript | 6 ++++++ readme.md | 5 +++-- tests/test.ts | 1 + tests/test_all_lxc | 2 ++ 6 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 lxc/executors/typescript create mode 100644 tests/test.ts diff --git a/api/main.go b/api/main.go index 423952e..424befb 100644 --- a/api/main.go +++ b/api/main.go @@ -54,6 +54,7 @@ func Execute(res http.ResponseWriter, req *http.Request) { "java", "nasm", "asm", "javascript", "js", "node", + "typescript", "ts", "php", "python", "python2", "python3", "r", diff --git a/lxc/execute b/lxc/execute index 8362a74..8bbea7d 100755 --- a/lxc/execute +++ b/lxc/execute @@ -90,6 +90,9 @@ case "$lang" in "bash") bin=bash ;; +"typescript" | "ts") + bin=typescript + ;; *) echo "invalid language" exit diff --git a/lxc/executors/typescript b/lxc/executors/typescript new file mode 100755 index 0000000..f3aff9a --- /dev/null +++ b/lxc/executors/typescript @@ -0,0 +1,6 @@ +cd /tmp/$2 +mv code.code interim.ts +timeout -s KILL 10 tsc interim.ts +rm interim.ts +mv interim.js code.code +runuser -l runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 nodejs code.code" diff --git a/readme.md b/readme.md index 3b42b13..20350dd 100644 --- a/readme.md +++ b/readme.md @@ -39,8 +39,9 @@ sed -i \ apt-get update apt-get -y install git tzdata nano \ dpkg-dev build-essential python python3 \ - ruby nodejs golang php7.2 r-base mono-complete \ + ruby nodejs npm golang php7.2 r-base mono-complete \ nasm openjdk-8-jdk ubuntu-make bf +npm install -g typescript umake swift ln -s /opt/.local/share/umake/swift/swift-lang/usr/bin/swift /usr/bin/swift curl https://sh.rustup.rs > rust.sh @@ -106,7 +107,7 @@ If an invalid language is supplied, a typical response will look like the follow ``` #### Supported Languages -Currently python2, python3, c, c++, go, node, ruby, r, c#, nasm, php, java, swift, brainfuck, rust, and bash is supported. +Currently python2, python3, c, c++, go, node, ruby, r, c#, nasm, php, java, swift, brainfuck, rust, bash, and typescript is supported. #### Principle of Operation Piston utilizes LXC as the primary mechanism for sandboxing. There is a small API written in Go which takes diff --git a/tests/test.ts b/tests/test.ts new file mode 100644 index 0000000..847245f --- /dev/null +++ b/tests/test.ts @@ -0,0 +1 @@ +console.log('good') diff --git a/tests/test_all_lxc b/tests/test_all_lxc index 1bd9edf..510d177 100755 --- a/tests/test_all_lxc +++ b/tests/test_all_lxc @@ -32,3 +32,5 @@ echo 'testing swift' ../lxc/execute swift test.swift echo 'testing bash' ../lxc/execute bash test.sh +echo 'testing typescript' +../lxc/execute typescript test.ts