diff --git a/.github/workflows/api-push.yaml b/.github/workflows/api-push.yaml index dec3bce..782554d 100644 --- a/.github/workflows/api-push.yaml +++ b/.github/workflows/api-push.yaml @@ -13,22 +13,22 @@ jobs: name: Build and Push Docker image to Github Packages steps: - name: Check out repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Login to GitHub registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: docker.pkg.github.com - name: Login to ghcr.io - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io - name: Build and push API - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: api push: true diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index d5bfe78..e0c5e12 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Get list of changed files uses: lots0logs/gh-action-get-changed-files@2.1.4 with: @@ -36,10 +36,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Login to GitHub registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -60,7 +60,7 @@ jobs: ls -la packages - name: Upload package as artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: packages path: packages/*.pkg.tar.gz @@ -70,9 +70,9 @@ jobs: runs-on: ubuntu-latest needs: build-pkg steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: packages @@ -80,7 +80,7 @@ jobs: run: mv *.pkg.tar.gz packages/ - name: Login to GitHub registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -92,7 +92,7 @@ jobs: docker run -v $(pwd)'/repo:/piston/repo' -v $(pwd)'/packages:/piston/packages' -d --name repo docker.pkg.github.com/engineer-man/piston/repo-builder --no-build docker pull docker.pkg.github.com/engineer-man/piston/api docker build -t piston-api api - docker run --network container:repo -v $(pwd)'/data:/piston' -e PISTON_LOG_LEVEL=DEBUG -e 'PISTON_REPO_URL=http://localhost:8000/index' -d --name api piston-api + docker run --privileged --network container:repo -v $(pwd)'/data:/piston' -e PISTON_LOG_LEVEL=DEBUG -e 'PISTON_REPO_URL=http://localhost:8000/index' -d --name api piston-api echo Waiting for API to start.. docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/api/v2/runtimes diff --git a/.github/workflows/package-push.yaml b/.github/workflows/package-push.yaml index 9de6051..5dd30dc 100644 --- a/.github/workflows/package-push.yaml +++ b/.github/workflows/package-push.yaml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Login to GitHub registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/repo-push.yaml b/.github/workflows/repo-push.yaml index c887b01..107edfd 100644 --- a/.github/workflows/repo-push.yaml +++ b/.github/workflows/repo-push.yaml @@ -13,16 +13,16 @@ jobs: name: Build and Push Docker image to Github Packages steps: - name: Check out repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Login to GitHub registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: docker.pkg.github.com - name: Build and push repo - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: repo pull: true diff --git a/api/Dockerfile b/api/Dockerfile index ec0d2a8..7ab81bf 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,20 +1,29 @@ +FROM buildpack-deps:buster AS isolate +RUN apt-get update && \ + apt-get install -y --no-install-recommends git libcap-dev && \ + rm -rf /var/lib/apt/lists/* && \ + git clone https://github.com/envicutor/isolate.git /tmp/isolate/ && \ + cd /tmp/isolate && \ + git checkout af6db68042c3aa0ded80787fbb78bc0846ea2114 && \ + make -j$(nproc) install && \ + rm -rf /tmp/* + FROM node:15.10.0-buster-slim ENV DEBIAN_FRONTEND=noninteractive RUN dpkg-reconfigure -p critical dash -RUN for i in $(seq 1001 1500); do \ - groupadd -g $i runner$i && \ - useradd -M runner$i -g $i -u $i ; \ - done 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 \ libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev \ libfftw3-dev libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev \ - libsundials-dev libpcre2-dev && \ + libsundials-dev libpcre2-dev libcap-dev && \ rm -rf /var/lib/apt/lists/* +RUN useradd -M piston +COPY --from=isolate /usr/local/bin/isolate /usr/local/bin +COPY --from=isolate /usr/local/etc/isolate /usr/local/etc/isolate RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen @@ -23,7 +32,5 @@ COPY ["package.json", "package-lock.json", "./"] RUN npm install COPY ./src ./src -RUN make -C ./src/nosocket/ all && make -C ./src/nosocket/ install - -CMD [ "node", "src"] +CMD ["/piston_api/src/docker-entrypoint.sh"] EXPOSE 2000/tcp diff --git a/api/package-lock.json b/api/package-lock.json index 2b34fc4..549e28f 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "body-parser": "^1.19.0", "chownr": "^2.0.0", - "express": "^4.17.1", + "express": "^4.17.3", "express-ws": "^5.0.2", "is-docker": "^2.1.1", "logplease": "^1.2.15", @@ -23,12 +23,12 @@ } }, "node_modules/accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "dependencies": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "mime-types": "~2.1.34", + "negotiator": "0.6.3" }, "engines": { "node": ">= 0.6" @@ -40,29 +40,29 @@ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, "node_modules/body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==", "dependencies": { - "bytes": "3.1.0", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "1.7.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "qs": "6.9.7", + "raw-body": "2.4.3", + "type-is": "~1.6.18" }, "engines": { "node": ">= 0.8" } }, "node_modules/bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "engines": { "node": ">= 0.8" } @@ -76,11 +76,11 @@ } }, "node_modules/content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "dependencies": { - "safe-buffer": "5.1.2" + "safe-buffer": "5.2.1" }, "engines": { "node": ">= 0.6" @@ -95,9 +95,9 @@ } }, "node_modules/cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", "engines": { "node": ">= 0.6" } @@ -126,7 +126,7 @@ "node_modules/destroy": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==" }, "node_modules/ee-first": { "version": "1.1.1", @@ -149,22 +149,22 @@ "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "engines": { "node": ">= 0.6" } }, "node_modules/express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.3.tgz", + "integrity": "sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg==", "dependencies": { - "accepts": "~1.3.7", + "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", + "body-parser": "1.19.2", + "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.0", + "cookie": "0.4.2", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~1.1.2", @@ -178,13 +178,13 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", + "proxy-addr": "~2.0.7", + "qs": "6.9.7", "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", + "safe-buffer": "5.2.1", + "send": "0.17.2", + "serve-static": "1.14.2", + "setprototypeof": "1.2.0", "statuses": "~1.5.0", "type-is": "~1.6.18", "utils-merge": "1.0.1", @@ -226,9 +226,9 @@ } }, "node_modules/forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", "engines": { "node": ">= 0.6" } @@ -236,21 +236,21 @@ "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "engines": { "node": ">= 0.6" } }, "node_modules/http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", "dependencies": { "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "toidentifier": "1.0.1" }, "engines": { "node": ">= 0.6" @@ -268,9 +268,9 @@ } }, "node_modules/inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/ipaddr.js": { "version": "1.9.1", @@ -340,19 +340,19 @@ } }, "node_modules/mime-db": { - "version": "1.46.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz", - "integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==", + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.29", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz", - "integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dependencies": { - "mime-db": "1.46.0" + "mime-db": "1.52.0" }, "engines": { "node": ">= 0.6" @@ -364,9 +364,9 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "node_modules/negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "engines": { "node": ">= 0.6" } @@ -407,11 +407,11 @@ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, "node_modules/proxy-addr": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", - "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", "dependencies": { - "forwarded": "~0.1.2", + "forwarded": "0.2.0", "ipaddr.js": "1.9.1" }, "engines": { @@ -419,11 +419,14 @@ } }, "node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", "engines": { "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/range-parser": { @@ -435,12 +438,12 @@ } }, "node_modules/raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", + "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", "dependencies": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "unpipe": "1.0.0" }, @@ -449,9 +452,23 @@ } }, "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/safer-buffer": { "version": "2.1.2", @@ -473,9 +490,9 @@ } }, "node_modules/send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", "dependencies": { "debug": "2.6.9", "depd": "~1.1.2", @@ -484,9 +501,9 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "1.8.1", "mime": "1.6.0", - "ms": "2.1.1", + "ms": "2.1.3", "on-finished": "~2.3.0", "range-parser": "~1.2.1", "statuses": "~1.5.0" @@ -496,28 +513,28 @@ } }, "node_modules/send/node_modules/ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", + "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.17.2" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "node_modules/statuses": { "version": "1.5.0", @@ -528,9 +545,9 @@ } }, "node_modules/toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "engines": { "node": ">=0.6" } @@ -611,12 +628,12 @@ }, "dependencies": { "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "mime-types": "~2.1.34", + "negotiator": "0.6.3" } }, "array-flatten": { @@ -625,26 +642,26 @@ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==", "requires": { - "bytes": "3.1.0", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "1.7.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "qs": "6.9.7", + "raw-body": "2.4.3", + "type-is": "~1.6.18" } }, "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, "chownr": { "version": "2.0.0", @@ -652,11 +669,11 @@ "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" }, "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "5.2.1" } }, "content-type": { @@ -665,9 +682,9 @@ "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, "cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" }, "cookie-signature": { "version": "1.0.6", @@ -690,7 +707,7 @@ "destroy": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==" }, "ee-first": { "version": "1.1.1", @@ -710,19 +727,19 @@ "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" }, "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.3.tgz", + "integrity": "sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg==", "requires": { - "accepts": "~1.3.7", + "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", + "body-parser": "1.19.2", + "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.0", + "cookie": "0.4.2", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~1.1.2", @@ -736,13 +753,13 @@ "on-finished": "~2.3.0", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", + "proxy-addr": "~2.0.7", + "qs": "6.9.7", "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", + "safe-buffer": "5.2.1", + "send": "0.17.2", + "serve-static": "1.14.2", + "setprototypeof": "1.2.0", "statuses": "~1.5.0", "type-is": "~1.6.18", "utils-merge": "1.0.1", @@ -772,25 +789,25 @@ } }, "forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" }, "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" }, "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", "requires": { "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "toidentifier": "1.0.1" } }, "iconv-lite": { @@ -802,9 +819,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ipaddr.js": { "version": "1.9.1", @@ -850,16 +867,16 @@ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.46.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz", - "integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==" + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" }, "mime-types": { - "version": "2.1.29", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz", - "integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "requires": { - "mime-db": "1.46.0" + "mime-db": "1.52.0" } }, "ms": { @@ -868,9 +885,9 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, "nocamel": { "version": "git+ssh://git@github.com/HexF/nocamel.git#89a5bfbbd07c72c302d968b967d0f4fe54846544", @@ -900,18 +917,18 @@ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, "proxy-addr": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", - "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", "requires": { - "forwarded": "~0.1.2", + "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==" }, "range-parser": { "version": "1.2.1", @@ -919,20 +936,20 @@ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", + "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "1.8.1", "iconv-lite": "0.4.24", "unpipe": "1.0.0" } }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "safer-buffer": { "version": "2.1.2", @@ -948,9 +965,9 @@ } }, "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", + "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", "requires": { "debug": "2.6.9", "depd": "~1.1.2", @@ -959,36 +976,36 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "1.8.1", "mime": "1.6.0", - "ms": "2.1.1", + "ms": "2.1.3", "on-finished": "~2.3.0", "range-parser": "~1.2.1", "statuses": "~1.5.0" }, "dependencies": { "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" } } }, "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", + "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.17.2" } }, "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "statuses": { "version": "1.5.0", @@ -996,9 +1013,9 @@ "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, "type-is": { "version": "1.6.18", diff --git a/api/package.json b/api/package.json index fb107a5..0b91c01 100644 --- a/api/package.json +++ b/api/package.json @@ -1,12 +1,12 @@ { "name": "piston-api", - "version": "3.1.0", + "version": "3.1.1", "description": "API for piston - a high performance code execution engine", "main": "src/index.js", "dependencies": { "body-parser": "^1.19.0", "chownr": "^2.0.0", - "express": "^4.17.1", + "express": "^4.17.3", "express-ws": "^5.0.2", "is-docker": "^2.1.1", "logplease": "^1.2.15", diff --git a/api/src/api/v2.js b/api/src/api/v2.js index 4f0c3e2..f8e2b57 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -6,50 +6,9 @@ const events = require('events'); const runtime = require('../runtime'); const { Job } = require('../job'); const package = require('../package'); +const globals = require('../globals'); const logger = require('logplease').create('api/v2'); -const SIGNALS = [ - 'SIGABRT', - 'SIGALRM', - 'SIGBUS', - 'SIGCHLD', - 'SIGCLD', - 'SIGCONT', - 'SIGEMT', - 'SIGFPE', - 'SIGHUP', - 'SIGILL', - 'SIGINFO', - 'SIGINT', - 'SIGIO', - 'SIGIOT', - 'SIGKILL', - 'SIGLOST', - 'SIGPIPE', - 'SIGPOLL', - 'SIGPROF', - 'SIGPWR', - 'SIGQUIT', - 'SIGSEGV', - 'SIGSTKFLT', - 'SIGSTOP', - 'SIGTSTP', - 'SIGSYS', - 'SIGTERM', - 'SIGTRAP', - 'SIGTTIN', - 'SIGTTOU', - 'SIGUNUSED', - 'SIGURG', - 'SIGUSR1', - 'SIGUSR2', - 'SIGVTALRM', - 'SIGXCPU', - 'SIGXFSZ', - 'SIGWINCH', -]; -// ref: https://man7.org/linux/man-pages/man7/signal.7.html - function get_job(body) { let { language, @@ -61,6 +20,8 @@ function get_job(body) { run_memory_limit, run_timeout, compile_timeout, + run_cpu_time, + compile_cpu_time, } = body; return new Promise((resolve, reject) => { @@ -106,7 +67,7 @@ function get_job(body) { }); } - for (const constraint of ['memory_limit', 'timeout']) { + for (const constraint of ['memory_limit', 'timeout', 'cpu_time']) { for (const type of ['compile', 'run']) { const constraint_name = `${type}_${constraint}`; const constraint_value = body[constraint_name]; @@ -135,23 +96,23 @@ function get_job(body) { } } - compile_timeout = compile_timeout || rt.timeouts.compile; - run_timeout = run_timeout || rt.timeouts.run; - compile_memory_limit = compile_memory_limit || rt.memory_limits.compile; - run_memory_limit = run_memory_limit || rt.memory_limits.run; resolve( new Job({ runtime: rt, - args: args || [], - stdin: stdin || '', + args: args ?? [], + stdin: stdin ?? '', files, timeouts: { - run: run_timeout, - compile: compile_timeout, + run: run_timeout ?? rt.timeouts.run, + compile: compile_timeout ?? rt.timeouts.compile, + }, + cpu_times: { + run: run_cpu_time ?? rt.cpu_times.run, + compile: compile_cpu_time ?? rt.cpu_times.compile, }, memory_limits: { - run: run_memory_limit, - compile: compile_memory_limit, + run: run_memory_limit ?? rt.memory_limits.run, + compile: compile_memory_limit ?? rt.memory_limits.compile, }, }) ); @@ -163,7 +124,7 @@ router.use((req, res, next) => { return next(); } - if (!req.headers['content-type'].startsWith('application/json')) { + if (!req.headers['content-type']?.startsWith('application/json')) { return res.status(415).send({ message: 'requests must be of type application/json', }); @@ -174,9 +135,9 @@ router.use((req, res, next) => { router.ws('/connect', async (ws, req) => { let job = null; - let eventBus = new events.EventEmitter(); + let event_bus = new events.EventEmitter(); - eventBus.on('stdout', data => + event_bus.on('stdout', data => ws.send( JSON.stringify({ type: 'data', @@ -185,7 +146,7 @@ router.ws('/connect', async (ws, req) => { }) ) ); - eventBus.on('stderr', data => + event_bus.on('stderr', data => ws.send( JSON.stringify({ type: 'data', @@ -194,10 +155,10 @@ router.ws('/connect', async (ws, req) => { }) ) ); - eventBus.on('stage', stage => + event_bus.on('stage', stage => ws.send(JSON.stringify({ type: 'stage', stage })) ); - eventBus.on('exit', (stage, status) => + event_bus.on('exit', (stage, status) => ws.send(JSON.stringify({ type: 'exit', stage, ...status })) ); @@ -210,19 +171,27 @@ router.ws('/connect', async (ws, req) => { if (job === null) { job = await get_job(msg); - await job.prime(); + try { + const box = await job.prime(); - ws.send( - JSON.stringify({ - type: 'runtime', - language: job.runtime.language, - version: job.runtime.version.raw, - }) - ); + ws.send( + JSON.stringify({ + type: 'runtime', + language: job.runtime.language, + version: job.runtime.version.raw, + }) + ); - await job.execute_interactive(eventBus); - - ws.close(4999, 'Job Completed'); + await job.execute(box, event_bus); + } catch (error) { + logger.error( + `Error cleaning up job: ${job.uuid}:\n${error}` + ); + throw error; + } finally { + await job.cleanup(); + } + ws.close(4999, 'Job Completed'); // Will not execute if an error is thrown above } else { ws.close(4000, 'Already Initialized'); } @@ -230,7 +199,7 @@ router.ws('/connect', async (ws, req) => { case 'data': if (job !== null) { if (msg.stream === 'stdin') { - eventBus.emit('stdin', msg.data); + event_bus.emit('stdin', msg.data); } else { ws.close(4004, 'Can only write to stdin'); } @@ -240,8 +209,10 @@ router.ws('/connect', async (ws, req) => { break; case 'signal': if (job !== null) { - if (SIGNALS.includes(msg.signal)) { - eventBus.emit('signal', msg.signal); + if ( + Object.values(globals.SIGNALS).includes(msg.signal) + ) { + event_bus.emit('signal', msg.signal); } else { ws.close(4005, 'Invalid signal'); } @@ -257,12 +228,6 @@ router.ws('/connect', async (ws, req) => { } }); - ws.on('close', async () => { - if (job !== null) { - await job.cleanup(); - } - }); - setTimeout(() => { //Terminate the socket after 1 second, if not initialized. if (job === null) ws.close(4001, 'Initialization Timeout'); @@ -270,18 +235,32 @@ router.ws('/connect', async (ws, req) => { }); router.post('/execute', async (req, res) => { + let job; try { - const job = await get_job(req.body); + job = await get_job(req.body); + } catch (error) { + return res.status(400).json(error); + } + try { + const box = await job.prime(); - await job.prime(); - - const result = await job.execute(); - - await job.cleanup(); + let result = await job.execute(box); + // Backward compatibility when the run stage is not started + if (result.run === undefined) { + result.run = result.compile; + } return res.status(200).send(result); } catch (error) { - return res.status(400).json(error); + logger.error(`Error executing job: ${job.uuid}:\n${error}`); + return res.status(500).send(); + } finally { + try { + await job.cleanup(); // This gets executed before the returns in try/catch + } catch (error) { + logger.error(`Error cleaning up job: ${job.uuid}:\n${error}`); + return res.status(500).send(); // On error, this replaces the return in the outer try-catch + } } }); diff --git a/api/src/config.js b/api/src/config.js index b8fa97d..034e3b6 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -90,6 +90,18 @@ const options = { parser: parse_int, validators: [(x, raw) => !is_nan(x) || `${raw} is not a number`], }, + compile_cpu_time: { + desc: 'Max CPU time allowed for compile stage in milliseconds', + default: 10000, // 10 seconds + parser: parse_int, + validators: [(x, raw) => !is_nan(x) || `${raw} is not a number`], + }, + run_cpu_time: { + desc: 'Max CPU time allowed for run stage in milliseconds', + default: 3000, // 3 seconds + parser: parse_int, + validators: [(x, raw) => !is_nan(x) || `${raw} is not a number`], + }, compile_memory_limit: { desc: 'Max memory usage for compile stage in bytes (set to -1 for no limit)', default: -1, // no limit @@ -117,7 +129,7 @@ const options = { limit_overrides: { desc: 'Per-language exceptions in JSON format for each of:\ max_process_count, max_open_files, max_file_size, compile_memory_limit,\ - run_memory_limit, compile_timeout, run_timeout, output_max_size', + run_memory_limit, compile_timeout, run_timeout, compile_cpu_time, run_cpu_time, output_max_size', default: {}, parser: parse_overrides, validators: [ @@ -165,6 +177,8 @@ function parse_overrides(overrides_string) { 'run_memory_limit', 'compile_timeout', 'run_timeout', + 'compile_cpu_time', + 'run_cpu_time', 'output_max_size', ].includes(key) ) { diff --git a/api/src/docker-entrypoint.sh b/api/src/docker-entrypoint.sh new file mode 100755 index 0000000..2a4e49c --- /dev/null +++ b/api/src/docker-entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +CGROUP_FS="/sys/fs/cgroup" +if [ ! -e "$CGROUP_FS" ]; then + echo "Cannot find $CGROUP_FS. Please make sure your system is using cgroup v2" + exit 1 +fi + +if [ -e "$CGROUP_FS/unified" ]; then + echo "Combined cgroup v1+v2 mode is not supported. Please make sure your system is using pure cgroup v2" + exit 1 +fi + +if [ ! -e "$CGROUP_FS/cgroup.subtree_control" ]; then + echo "Cgroup v2 not found. Please make sure cgroup v2 is enabled on your system" + exit 1 +fi + +cd /sys/fs/cgroup && \ +mkdir isolate/ && \ +echo 1 > isolate/cgroup.procs && \ +echo '+cpuset +cpu +io +memory +pids' > cgroup.subtree_control && \ +cd isolate && \ +mkdir init && \ +echo 1 > init/cgroup.procs && \ +echo '+cpuset +memory' > cgroup.subtree_control && \ +echo "Initialized cgroup" && \ +chown -R piston:piston /piston && \ +exec su -- piston -c 'ulimit -n 65536 && node /piston_api/src' diff --git a/api/src/globals.js b/api/src/globals.js index 933d2ca..c2fef42 100644 --- a/api/src/globals.js +++ b/api/src/globals.js @@ -7,14 +7,78 @@ const platform = `${is_docker() ? 'docker' : 'baremetal'}-${fs .split('\n') .find(x => x.startsWith('ID')) .replace('ID=', '')}`; +const SIGNALS = { + 1: 'SIGHUP', + 2: 'SIGINT', + 3: 'SIGQUIT', + 4: 'SIGILL', + 5: 'SIGTRAP', + 6: 'SIGABRT', + 7: 'SIGBUS', + 8: 'SIGFPE', + 9: 'SIGKILL', + 10: 'SIGUSR1', + 11: 'SIGSEGV', + 12: 'SIGUSR2', + 13: 'SIGPIPE', + 14: 'SIGALRM', + 15: 'SIGTERM', + 16: 'SIGSTKFLT', + 17: 'SIGCHLD', + 18: 'SIGCONT', + 19: 'SIGSTOP', + 20: 'SIGTSTP', + 21: 'SIGTTIN', + 22: 'SIGTTOU', + 23: 'SIGURG', + 24: 'SIGXCPU', + 25: 'SIGXFSZ', + 26: 'SIGVTALRM', + 27: 'SIGPROF', + 28: 'SIGWINCH', + 29: 'SIGIO', + 30: 'SIGPWR', + 31: 'SIGSYS', + 34: 'SIGRTMIN', + 35: 'SIGRTMIN+1', + 36: 'SIGRTMIN+2', + 37: 'SIGRTMIN+3', + 38: 'SIGRTMIN+4', + 39: 'SIGRTMIN+5', + 40: 'SIGRTMIN+6', + 41: 'SIGRTMIN+7', + 42: 'SIGRTMIN+8', + 43: 'SIGRTMIN+9', + 44: 'SIGRTMIN+10', + 45: 'SIGRTMIN+11', + 46: 'SIGRTMIN+12', + 47: 'SIGRTMIN+13', + 48: 'SIGRTMIN+14', + 49: 'SIGRTMIN+15', + 50: 'SIGRTMAX-14', + 51: 'SIGRTMAX-13', + 52: 'SIGRTMAX-12', + 53: 'SIGRTMAX-11', + 54: 'SIGRTMAX-10', + 55: 'SIGRTMAX-9', + 56: 'SIGRTMAX-8', + 57: 'SIGRTMAX-7', + 58: 'SIGRTMAX-6', + 59: 'SIGRTMAX-5', + 60: 'SIGRTMAX-4', + 61: 'SIGRTMAX-3', + 62: 'SIGRTMAX-2', + 63: 'SIGRTMAX-1', + 64: 'SIGRTMAX', +}; module.exports = { data_directories: { packages: 'packages', - jobs: 'jobs', }, version: require('../package.json').version, platform, pkg_installed_file: '.ppman-installed', //Used as indication for if a package was installed clean_directories: ['/dev/shm', '/run/lock', '/tmp', '/var/tmp'], + SIGNALS, }; diff --git a/api/src/index.js b/api/src/index.js index 2870902..4a6dd42 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -35,7 +35,6 @@ expressWs(app); } } }); - fss.chmodSync(path.join(config.data_directory, globals.data_directories.jobs), 0o711) logger.info('Loading packages'); const pkgdir = path.join( @@ -79,6 +78,12 @@ expressWs(app); const api_v2 = require('./api/v2'); app.use('/api/v2', api_v2); + const { version } = require('../package.json'); + + app.get('/', (req, res, next) => { + return res.status(200).send({ message: `Piston v${version}` }); + }); + app.use((req, res, next) => { return res.status(404).send({ message: 'Not Found' }); }); @@ -86,7 +91,12 @@ expressWs(app); logger.debug('Calling app.listen'); const [address, port] = config.bind_address.split(':'); - app.listen(port, address, () => { + const server = app.listen(port, address, () => { logger.info('API server started on', config.bind_address); }); + + process.on('SIGTERM', () => { + server.close(); + process.exit(0) + }); })(); diff --git a/api/src/job.js b/api/src/job.js index ecc19e5..8c3fa79 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -1,13 +1,10 @@ const logplease = require('logplease'); -const logger = logplease.create('job'); const { v4: uuidv4 } = require('uuid'); const cp = require('child_process'); const path = require('path'); const config = require('./config'); -const globals = require('./globals'); const fs = require('fs/promises'); -const fss = require('fs'); -const wait_pid = require('waitpid'); +const globals = require('./globals'); const job_states = { READY: Symbol('Ready to be primed'), @@ -15,21 +12,26 @@ const job_states = { EXECUTED: Symbol('Executed and ready for cleanup'), }; -let uid = 0; -let gid = 0; +const MAX_BOX_ID = 999; +const ISOLATE_PATH = '/usr/local/bin/isolate'; +let box_id = 0; let remaining_job_spaces = config.max_concurrent_jobs; -let jobQueue = []; +let job_queue = []; -setInterval(() => { - // Every 10ms try resolve a new job, if there is an available slot - if (jobQueue.length > 0 && remaining_job_spaces > 0) { - jobQueue.shift()(); - } -}, 10); +const get_next_box_id = () => ++box_id % MAX_BOX_ID; class Job { - constructor({ runtime, files, args, stdin, timeouts, memory_limits }) { + #dirty_boxes; + constructor({ + runtime, + files, + args, + stdin, + timeouts, + cpu_times, + memory_limits, + }) { this.uuid = uuidv4(); this.logger = logplease.create(`job/${this.uuid}`); @@ -45,187 +47,282 @@ class Job { this.args = args; this.stdin = stdin; + // Add a trailing newline if it doesn't exist + if (this.stdin.slice(-1) !== '\n') { + this.stdin += '\n'; + } this.timeouts = timeouts; + this.cpu_times = cpu_times; this.memory_limits = memory_limits; - this.uid = config.runner_uid_min + uid; - this.gid = config.runner_gid_min + gid; - - uid++; - gid++; - - uid %= config.runner_uid_max - config.runner_uid_min + 1; - gid %= config.runner_gid_max - config.runner_gid_min + 1; - - this.logger.debug(`Assigned uid=${this.uid} gid=${this.gid}`); - this.state = job_states.READY; - this.dir = path.join( - config.data_directory, - globals.data_directories.jobs, - this.uuid - ); + this.#dirty_boxes = []; + } + + async #create_isolate_box() { + const box_id = get_next_box_id(); + const metadata_file_path = `/tmp/${box_id}-metadata.txt`; + return new Promise((res, rej) => { + cp.exec( + `isolate --init --cg -b${box_id}`, + (error, stdout, stderr) => { + if (error) { + rej( + `Failed to run isolate --init: ${error.message}\nstdout: ${stdout}\nstderr: ${stderr}` + ); + } + if (stdout === '') { + rej('Received empty stdout from isolate --init'); + } + const box = { + id: box_id, + metadata_file_path, + dir: `${stdout.trim()}/box`, + }; + this.#dirty_boxes.push(box); + res(box); + } + ); + }); } async prime() { if (remaining_job_spaces < 1) { this.logger.info(`Awaiting job slot`); await new Promise(resolve => { - jobQueue.push(resolve); + job_queue.push(resolve); }); } - this.logger.info(`Priming job`); remaining_job_spaces--; - this.logger.debug('Writing files to job cache'); - - this.logger.debug(`Transfering ownership`); - - await fs.mkdir(this.dir, { mode: 0o700 }); - await fs.chown(this.dir, this.uid, this.gid); + this.logger.debug('Running isolate --init'); + const box = await this.#create_isolate_box(); + this.logger.debug(`Creating submission files in Isolate box`); + const submission_dir = path.join(box.dir, 'submission'); + await fs.mkdir(submission_dir); for (const file of this.files) { - const file_path = path.join(this.dir, file.name); - const rel = path.relative(this.dir, file_path); - const file_content = Buffer.from(file.content, file.encoding); + const file_path = path.join(submission_dir, file.name); + const rel = path.relative(submission_dir, file_path); if (rel.startsWith('..')) throw Error( `File path "${file.name}" tries to escape parent directory: ${rel}` ); + const file_content = Buffer.from(file.content, file.encoding); + await fs.mkdir(path.dirname(file_path), { recursive: true, mode: 0o700, }); - await fs.chown(path.dirname(file_path), this.uid, this.gid); - await fs.write_file(file_path, file_content); - await fs.chown(file_path, this.uid, this.gid); } this.state = job_states.PRIMED; this.logger.debug('Primed job'); + return box; } - async safe_call(file, args, timeout, memory_limit, eventBus = null) { - return new Promise((resolve, reject) => { - const nonetwork = config.disable_networking ? ['nosocket'] : []; + async safe_call( + box, + file, + args, + timeout, + cpu_time, + memory_limit, + event_bus = null + ) { + let stdout = ''; + let stderr = ''; + let output = ''; + let memory = null; + let code = null; + let signal = null; + let message = null; + let status = null; + let cpu_time_stat = null; + let wall_time_stat = null; - const prlimit = [ - 'prlimit', - '--nproc=' + this.runtime.max_process_count, - '--nofile=' + this.runtime.max_open_files, - '--fsize=' + this.runtime.max_file_size, - ]; - - const timeout_call = [ - 'timeout', '-s', '9', Math.ceil(timeout / 1000), - ]; - - if (memory_limit >= 0) { - prlimit.push('--as=' + memory_limit); - } - - const proc_call = [ - 'nice', - ...timeout_call, - ...prlimit, - ...nonetwork, - 'bash', - file, + const proc = cp.spawn( + ISOLATE_PATH, + [ + '--run', + `-b${box.id}`, + `--meta=${box.metadata_file_path}`, + '--cg', + '-s', + '-c', + '/box/submission', + '-E', + 'HOME=/tmp', + ...this.runtime.env_vars.flat_map(v => ['-E', v]), + '-E', + `PISTON_LANGUAGE=${this.runtime.language}`, + `--dir=${this.runtime.pkgdir}`, + `--dir=/etc:noexec`, + `--processes=${this.runtime.max_process_count}`, + `--open-files=${this.runtime.max_open_files}`, + `--fsize=${Math.floor(this.runtime.max_file_size / 1000)}`, + `--wall-time=${timeout / 1000}`, + `--time=${cpu_time / 1000}`, + `--extra-time=0`, + ...(memory_limit >= 0 + ? [`--cg-mem=${Math.floor(memory_limit / 1000)}`] + : []), + ...(config.disable_networking ? [] : ['--share-net']), + '--', + '/bin/bash', + path.join(this.runtime.pkgdir, file), ...args, - ]; - - var stdout = ''; - var stderr = ''; - var output = ''; - - const proc = cp.spawn(proc_call[0], proc_call.splice(1), { - env: { - ...this.runtime.env_vars, - PISTON_LANGUAGE: this.runtime.language, - }, + ], + { stdio: 'pipe', - cwd: this.dir, - uid: this.uid, - gid: this.gid, - detached: true, //give this process its own process group - }); - - if (eventBus === null) { - proc.stdin.write(this.stdin); - proc.stdin.end(); - proc.stdin.destroy(); - } else { - eventBus.on('stdin', data => { - proc.stdin.write(data); - }); - - eventBus.on('kill', signal => { - proc.kill(signal); - }); } + ); - const kill_timeout = - (timeout >= 0 && - set_timeout(async _ => { - this.logger.info(`Timeout exceeded timeout=${timeout}`); - process.kill(proc.pid, 'SIGKILL'); - }, timeout)) || - null; - - proc.stderr.on('data', async data => { - if (eventBus !== null) { - eventBus.emit('stderr', data); - } else if (stderr.length > this.runtime.output_max_size) { - this.logger.info(`stderr length exceeded`); - process.kill(proc.pid, 'SIGKILL'); - } else { - stderr += data; - output += data; - } + if (event_bus === null) { + proc.stdin.write(this.stdin); + proc.stdin.end(); + proc.stdin.destroy(); + } else { + event_bus.on('stdin', data => { + proc.stdin.write(data); }); - proc.stdout.on('data', async data => { - if (eventBus !== null) { - eventBus.emit('stdout', data); - } else if (stdout.length > this.runtime.output_max_size) { - this.logger.info(`stdout length exceeded`); - process.kill(proc.pid, 'SIGKILL'); - } else { - stdout += data; - output += data; - } + event_bus.on('kill', signal => { + proc.kill(signal); }); + } - const exit_cleanup = () => { - clear_timeout(kill_timeout); + proc.stderr.on('data', async data => { + if (event_bus !== null) { + event_bus.emit('stderr', data); + } else if ( + stderr.length + data.length > + this.runtime.output_max_size + ) { + message = 'stderr length exceeded'; + status = 'EL'; + this.logger.info(message); + try { + process.kill(proc.pid, 'SIGABRT'); + } catch (e) { + // Could already be dead and just needs to be waited on + this.logger.debug( + `Got error while SIGABRTing process ${proc}:`, + e + ); + } + } else { + stderr += data; + output += data; + } + }); - proc.stderr.destroy(); - proc.stdout.destroy(); + proc.stdout.on('data', async data => { + if (event_bus !== null) { + event_bus.emit('stdout', data); + } else if ( + stdout.length + data.length > + this.runtime.output_max_size + ) { + message = 'stdout length exceeded'; + status = 'OL'; + this.logger.info(message); + try { + process.kill(proc.pid, 'SIGABRT'); + } catch (e) { + // Could already be dead and just needs to be waited on + this.logger.debug( + `Got error while SIGABRTing process ${proc}:`, + e + ); + } + } else { + stdout += data; + output += data; + } + }); - this.cleanup_processes(); - this.logger.debug(`Finished exit cleanup`); - }; - - proc.on('exit', (code, signal) => { - exit_cleanup(); - - resolve({ stdout, stderr, code, signal, output }); + const data = await new Promise((res, rej) => { + proc.on('exit', (_, signal) => { + res({ + signal, + }); }); proc.on('error', err => { - exit_cleanup(); - - reject({ error: err, stdout, stderr, output }); + rej({ + error: err, + }); }); }); + + try { + const metadata_str = ( + await fs.read_file(box.metadata_file_path) + ).toString(); + const metadata_lines = metadata_str.split('\n'); + for (const line of metadata_lines) { + if (!line) continue; + + const [key, value] = line.split(':'); + if (key === undefined || value === undefined) { + throw new Error( + `Failed to parse metadata file, received: ${line}` + ); + } + switch (key) { + case 'cg-mem': + memory = parse_int(value) * 1000; + break; + case 'exitcode': + code = parse_int(value); + break; + case 'exitsig': + signal = globals.SIGNALS[parse_int(value)] ?? null; + break; + case 'message': + message = message || value; + break; + case 'status': + status = status || value; + break; + case 'time': + cpu_time_stat = parse_float(value) * 1000; + break; + case 'time-wall': + wall_time_stat = parse_float(value) * 1000; + break; + default: + break; + } + } + } catch (e) { + throw new Error( + `Error reading metadata file: ${box.metadata_file_path}\nError: ${e.message}\nIsolate run stdout: ${stdout}\nIsolate run stderr: ${stderr}` + ); + } + + return { + ...data, + stdout, + stderr, + code, + signal: ['TO', 'OL', 'EL'].includes(status) ? 'SIGKILL' : signal, + output, + memory, + message, + status, + cpu_time: cpu_time_stat, + wall_time: wall_time_stat, + }; } - async execute() { + async execute(box, event_bus = null) { if (this.state !== job_states.PRIMED) { throw new Error( 'Job must be in primed state, current state: ' + @@ -242,24 +339,66 @@ class Job { this.logger.debug('Compiling'); let compile; + let compile_errored = false; + const { emit_event_bus_result, emit_event_bus_stage } = + event_bus === null + ? { + emit_event_bus_result: () => {}, + emit_event_bus_stage: () => {}, + } + : { + emit_event_bus_result: (stage, result) => { + const { error, code, signal } = result; + event_bus.emit('exit', stage, { + error, + code, + signal, + }); + }, + emit_event_bus_stage: stage => { + event_bus.emit('stage', stage); + }, + }; if (this.runtime.compiled) { + this.logger.debug('Compiling'); + emit_event_bus_stage('compile'); compile = await this.safe_call( - path.join(this.runtime.pkgdir, 'compile'), + box, + 'compile', code_files.map(x => x.name), this.timeouts.compile, - this.memory_limits.compile + this.cpu_times.compile, + this.memory_limits.compile, + event_bus ); + emit_event_bus_result('compile', compile); + compile_errored = compile.code !== 0; + if (!compile_errored) { + const old_box_dir = box.dir; + box = await this.#create_isolate_box(); + await fs.rename( + path.join(old_box_dir, 'submission'), + path.join(box.dir, 'submission') + ); + } } - this.logger.debug('Running'); - - const run = await this.safe_call( - path.join(this.runtime.pkgdir, 'run'), - [code_files[0].name, ...this.args], - this.timeouts.run, - this.memory_limits.run - ); + let run; + if (!compile_errored) { + this.logger.debug('Running'); + emit_event_bus_stage('run'); + run = await this.safe_call( + box, + 'run', + [code_files[0].name, ...this.args], + this.timeouts.run, + this.cpu_times.run, + this.memory_limits.run, + event_bus + ); + emit_event_bus_result('run', run); + } this.state = job_states.EXECUTED; @@ -271,179 +410,34 @@ class Job { }; } - async execute_interactive(eventBus) { - if (this.state !== job_states.PRIMED) { - throw new Error( - 'Job must be in primed state, current state: ' + - this.state.toString() - ); - } - - this.logger.info( - `Interactively executing job runtime=${this.runtime.toString()}` - ); - - const code_files = - (this.runtime.language === 'file' && this.files) || - this.files.filter(file => file.encoding == 'utf8'); - - if (this.runtime.compiled) { - eventBus.emit('stage', 'compile'); - const { error, code, signal } = await this.safe_call( - path.join(this.runtime.pkgdir, 'compile'), - code_files.map(x => x.name), - this.timeouts.compile, - this.memory_limits.compile, - eventBus - ); - - eventBus.emit('exit', 'compile', { error, code, signal }); - } - - this.logger.debug('Running'); - eventBus.emit('stage', 'run'); - const { error, code, signal } = await this.safe_call( - path.join(this.runtime.pkgdir, 'run'), - [code_files[0].name, ...this.args], - this.timeouts.run, - this.memory_limits.run, - eventBus - ); - - eventBus.emit('exit', 'run', { error, code, signal }); - - this.state = job_states.EXECUTED; - } - - cleanup_processes(dont_wait = []) { - let processes = [1]; - const to_wait = []; - this.logger.debug(`Cleaning up processes`); - - while (processes.length > 0) { - processes = []; - - const proc_ids = fss.readdir_sync('/proc'); - - processes = proc_ids.map(proc_id => { - if (isNaN(proc_id)) return -1; - try { - const proc_status = fss.read_file_sync( - path.join('/proc', proc_id, 'status') - ); - const proc_lines = proc_status.to_string().split('\n'); - const state_line = proc_lines.find(line => - line.starts_with('State:') - ); - const uid_line = proc_lines.find(line => - line.starts_with('Uid:') - ); - const [_, ruid, euid, suid, fuid] = uid_line.split(/\s+/); - - const [_1, state, user_friendly] = state_line.split(/\s+/); - - const proc_id_int = parse_int(proc_id); - - // Skip over any processes that aren't ours. - if(ruid != this.uid && euid != this.uid) return -1; - - if (state == 'Z'){ - // Zombie process, just needs to be waited, regardless of the user id - if(!to_wait.includes(proc_id_int)) - to_wait.push(proc_id_int); - - return -1; - } - // We should kill in all other state (Sleep, Stopped & Running) - - return proc_id_int; - } catch { - return -1; - } - - return -1; - }); - - processes = processes.filter(p => p > 0); - - if (processes.length > 0) - this.logger.debug(`Got processes to kill: ${processes}`); - - for (const proc of processes) { - // First stop the processes, but keep their resources allocated so they cant re-fork - try { - process.kill(proc, 'SIGSTOP'); - } catch (e) { - // Could already be dead - this.logger.debug( - `Got error while SIGSTOPping process ${proc}:`, - e - ); - } - } - - for (const proc of processes) { - // Then clear them out of the process tree - try { - process.kill(proc, 'SIGKILL'); - } catch(e) { - // Could already be dead and just needs to be waited on - this.logger.debug( - `Got error while SIGKILLing process ${proc}:`, - e - ); - } - - to_wait.push(proc); - } - } - - this.logger.debug( - `Finished kill-loop, calling wait_pid to end any zombie processes` - ); - - for (const proc of to_wait) { - if (dont_wait.includes(proc)) continue; - - wait_pid(proc); - } - - this.logger.debug(`Cleaned up processes`); - } - - async cleanup_filesystem() { - for (const clean_path of globals.clean_directories) { - const contents = await fs.readdir(clean_path); - - for (const file of contents) { - const file_path = path.join(clean_path, file); - - try { - const stat = await fs.stat(file_path); - - if (stat.uid === this.uid) { - await fs.rm(file_path, { - recursive: true, - force: true, - }); - } - } catch (e) { - // File was somehow deleted in the time that we read the dir to when we checked the file - this.logger.warn(`Error removing file ${file_path}: ${e}`); - } - } - } - - await fs.rm(this.dir, { recursive: true, force: true }); - } - async cleanup() { this.logger.info(`Cleaning up job`); - this.cleanup_processes(); // Run process janitor, just incase there are any residual processes somehow - await this.cleanup_filesystem(); - remaining_job_spaces++; + if (job_queue.length > 0) { + job_queue.shift()(); + } + await Promise.all( + this.#dirty_boxes.map(async box => { + cp.exec( + `isolate --cleanup --cg -b${box.id}`, + (error, stdout, stderr) => { + if (error) { + this.logger.error( + `Failed to run isolate --cleanup: ${error.message} on box #${box.id}\nstdout: ${stdout}\nstderr: ${stderr}` + ); + } + } + ); + try { + await fs.rm(box.metadata_file_path); + } catch (e) { + this.logger.error( + `Failed to remove the metadata directory of box #${box.id}. Error: ${e.message}` + ); + } + }) + ); } } diff --git a/api/src/nosocket/Makefile b/api/src/nosocket/Makefile deleted file mode 100644 index a86a8f5..0000000 --- a/api/src/nosocket/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CC = gcc -CFLAGS = -O2 -Wall -lseccomp -TARGET = nosocket -BUILD_PATH = ./ -INSTALL_PATH = /usr/local/bin/ -SOURCE = nosocket.c - -all: $(TARGET) - -$(TARGET): $(SOURCE) - $(CC) $(BUILD_PATH)$(SOURCE) $(CFLAGS) -o $(TARGET) - -install: - mv $(TARGET) $(INSTALL_PATH) - -clean: - $(RM) $(TARGET) - $(RM) $(INSTALL_PATH)$(TARGET) - diff --git a/api/src/nosocket/nosocket.c b/api/src/nosocket/nosocket.c deleted file mode 100644 index 4efab88..0000000 --- a/api/src/nosocket/nosocket.c +++ /dev/null @@ -1,62 +0,0 @@ -/* -nosocket.c - -Disables access to the `socket` syscall and runs a program provided as the first -commandline argument. -*/ -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - // Disallow any new capabilities from being added - prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); - - // SCMP_ACT_ALLOW lets the filter have no effect on syscalls not matching a - // configured filter rule (allow all by default) - scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_ALLOW); - if (!ctx) - { - fprintf(stderr, "Unable to initialize seccomp filter context\n"); - return 1; - } - - // Add 32 bit and 64 bit architectures to seccomp filter - int rc; - uint32_t arch[] = {SCMP_ARCH_X86_64, SCMP_ARCH_X86, SCMP_ARCH_X32}; - // We first remove the existing arch, otherwise our subsequent call to add - // it will fail - seccomp_arch_remove(ctx, seccomp_arch_native()); - for (int i = 0; i < sizeof(arch) / sizeof(arch[0]); i++) - { - rc = seccomp_arch_add(ctx, arch[i]); - if (rc != 0) - { - fprintf(stderr, "Unable to add arch: %d\n", arch[i]); - return 1; - } - } - - // Add a seccomp rule to the syscall blacklist - blacklist the socket syscall - if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(socket), 0) < 0) - { - fprintf(stderr, "Unable to add seccomp rule to context\n"); - return 1; - } - -#ifdef DEBUG - seccomp_export_pfc(ctx, 0); -#endif - - if (argc < 2) - { - fprintf(stderr, "Usage %s: %s \n", argv[0], argv[0]); - return 1; - } - seccomp_load(ctx); - execvp(argv[1], argv + 1); - return 1; -} diff --git a/api/src/package.js b/api/src/package.js index 11e4f34..8edb008 100644 --- a/api/src/package.js +++ b/api/src/package.js @@ -145,7 +145,11 @@ class Package { await fs.write_file(path.join(this.install_path, '.env'), filtered_env); logger.debug('Changing Ownership of package directory'); - await util.promisify(chownr)(this.install_path, 0, 0); + await util.promisify(chownr)( + this.install_path, + process.getuid(), + process.getgid() + ); logger.debug('Writing installed state to disk'); await fs.write_file( diff --git a/api/src/runtime.js b/api/src/runtime.js index 6c6f10e..90a2225 100644 --- a/api/src/runtime.js +++ b/api/src/runtime.js @@ -15,6 +15,7 @@ class Runtime { pkgdir, runtime, timeouts, + cpu_times, memory_limits, max_process_count, max_open_files, @@ -27,6 +28,7 @@ class Runtime { this.pkgdir = pkgdir; this.runtime = runtime; this.timeouts = timeouts; + this.cpu_times = cpu_times; this.memory_limits = memory_limits; this.max_process_count = max_process_count; this.max_open_files = max_open_files; @@ -62,6 +64,18 @@ class Runtime { language_limit_overrides ), }, + cpu_times: { + compile: this.compute_single_limit( + language_name, + 'compile_cpu_time', + language_limit_overrides + ), + run: this.compute_single_limit( + language_name, + 'run_cpu_time', + language_limit_overrides + ), + }, memory_limits: { compile: this.compute_single_limit( language_name, @@ -164,15 +178,7 @@ class Runtime { const env_file = path.join(this.pkgdir, '.env'); const env_content = fss.read_file_sync(env_file).toString(); - this._env_vars = {}; - - env_content - .trim() - .split('\n') - .map(line => line.split('=', 2)) - .forEach(([key, val]) => { - this._env_vars[key.trim()] = val.trim(); - }); + this._env_vars = env_content.trim().split('\n'); } return this._env_vars; diff --git a/builder/build.sh b/builder/build.sh index eaae21d..8087e9f 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -23,20 +23,20 @@ fetch_packages(){ mkdir build # Start a piston container docker run \ + --privileged \ -v "$PWD/build":'/piston/packages' \ - --tmpfs /piston/jobs \ -dit \ -p $port:2000 \ --name builder_piston_instance \ ghcr.io/engineer-man/piston - + # Ensure the CLI is installed cd ../cli npm i cd - # Evalulate the specfile - ../cli/index.js -u "http://127.0.0.1:$port" ppman spec $1 + ../cli/index.js -u "http://127.0.0.1:$port" ppman spec $1 } build_container(){ @@ -61,4 +61,4 @@ fetch_packages $SPEC_FILE build_container $TAG echo "Start your custom piston container with" -echo "$ docker run --tmpfs /piston/jobs -dit -p 2000:2000 $TAG" +echo "$ docker run --privileged -dit -p 2000:2000 $TAG" diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 8a0d385..33f615d 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -4,8 +4,7 @@ services: api: build: api container_name: piston_api - cap_add: - - CAP_SYS_ADMIN + privileged: true restart: always ports: - 2000:2000 @@ -13,8 +12,6 @@ services: - ./data/piston/packages:/piston/packages environment: - PISTON_REPO_URL=http://repo:8000/index - tmpfs: - - /piston/jobs:exec,uid=1000,gid=1000,mode=711 repo: # Local testing of packages build: repo diff --git a/docker-compose.yaml b/docker-compose.yaml index 839b340..ea62b06 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,10 +5,10 @@ services: image: ghcr.io/engineer-man/piston container_name: piston_api restart: always + privileged: true ports: - 2000:2000 volumes: - ./data/piston/packages:/piston/packages tmpfs: - - /piston/jobs:exec,uid=1000,gid=1000,mode=711 - /tmp:exec diff --git a/docs/configuration.md b/docs/configuration.md index 1a6f5bd..163cd08 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -135,8 +135,21 @@ key: default: 3000 ``` -The maximum time that is allowed to be taken by a stage in milliseconds. -Use -1 for unlimited time. +The maximum time that is allowed to be taken by a stage in milliseconds. This is the wall-time of the stage. The time that the CPU does not spend working on the stage (e.g, due to context switches or IO) is counted. + +## Compile/Run CPU-Time + +```yaml +key: + - PISTON_COMPILE_CPU_TIME +default: 10000 + +key: + - PISTON_RUN_CPU_TIME +default: 3000 +``` + +The maximum CPU-time that is allowed to be consumed by a stage in milliseconds. The time that the CPU does not spend working on the stage (e.g, IO and context switches) is not counted. This option is typically used in algorithm contests. ## Compile/Run memory limits @@ -178,7 +191,7 @@ default: {} ``` Per-language overrides/exceptions for the each of `max_process_count`, `max_open_files`, `max_file_size`, -`compile_memory_limit`, `run_memory_limit`, `compile_timeout`, `run_timeout`, `output_max_size`. Defined as follows: +`compile_memory_limit`, `run_memory_limit`, `compile_timeout`, `run_timeout`, `compile_cpu_time`, `run_cpu_time`, `output_max_size`. Defined as follows: ``` PISTON_LIMIT_OVERRIDES={"c++":{"max_process_count":128}} diff --git a/packages/MATL/22.7.4/build.sh b/packages/MATL/22.7.4/build.sh new file mode 100644 index 0000000..106de4b --- /dev/null +++ b/packages/MATL/22.7.4/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# build octave as dependency +source ../../octave/6.2.0/build.sh + +# curl MATL 22.7.4 +curl -L "https://github.com/lmendo/MATL/archive/refs/tags/22.7.4.tar.gz" -o MATL.tar.xz +tar xf MATL.tar.xz --strip-components=1 +rm MATL.tar.xz \ No newline at end of file diff --git a/packages/MATL/22.7.4/environment b/packages/MATL/22.7.4/environment new file mode 100644 index 0000000..015acc2 --- /dev/null +++ b/packages/MATL/22.7.4/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Path to MATL binary +export PATH=$PWD/bin:$PATH +export MATL_PATH=$PWD \ No newline at end of file diff --git a/packages/MATL/22.7.4/metadata.json b/packages/MATL/22.7.4/metadata.json new file mode 100644 index 0000000..88a707d --- /dev/null +++ b/packages/MATL/22.7.4/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "matl", + "version": "22.7.4", + "aliases": [] +} \ No newline at end of file diff --git a/packages/MATL/22.7.4/run b/packages/MATL/22.7.4/run new file mode 100644 index 0000000..b0eb268 --- /dev/null +++ b/packages/MATL/22.7.4/run @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# get file as first argument +file="$1" + +# remove the file from $@ +shift + +# use the rest of the arguments as stdin +stdin=`printf "%s\n" "$@"` + +# pass stdin into octave which will run MATL +echo "$stdin" | octave -W -p "$MATL_PATH" --eval "matl -of '$file'" \ No newline at end of file diff --git a/packages/MATL/22.7.4/test.matl b/packages/MATL/22.7.4/test.matl new file mode 100644 index 0000000..97791fa --- /dev/null +++ b/packages/MATL/22.7.4/test.matl @@ -0,0 +1 @@ +'OK' \ No newline at end of file diff --git a/packages/bash/5.2.0/build.sh b/packages/bash/5.2.0/build.sh new file mode 100755 index 0000000..bddce57 --- /dev/null +++ b/packages/bash/5.2.0/build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Put instructions to build your package in here +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build + +curl "https://ftp.gnu.org/gnu/bash/bash-5.2.tar.gz" -o bash.tar.gz + +tar xzf bash.tar.gz --strip-components=1 + +# === autoconf based === +./configure --prefix "$PREFIX" + +make -j$(nproc) +make install -j$(nproc) +cd ../ +rm -rf build \ No newline at end of file diff --git a/packages/bash/5.2.0/environment b/packages/bash/5.2.0/environment new file mode 100644 index 0000000..c6ab089 --- /dev/null +++ b/packages/bash/5.2.0/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/bash/5.2.0/metadata.json b/packages/bash/5.2.0/metadata.json new file mode 100644 index 0000000..5082f8c --- /dev/null +++ b/packages/bash/5.2.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "bash", + "version": "5.2.0", + "aliases": ["sh"] +} \ No newline at end of file diff --git a/packages/bash/5.2.0/run b/packages/bash/5.2.0/run new file mode 100644 index 0000000..d20b2ba --- /dev/null +++ b/packages/bash/5.2.0/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put instructions to run the runtime +bash "$@" \ No newline at end of file diff --git a/packages/bash/5.2.0/test.bash.sh b/packages/bash/5.2.0/test.bash.sh new file mode 100644 index 0000000..727518f --- /dev/null +++ b/packages/bash/5.2.0/test.bash.sh @@ -0,0 +1 @@ +echo "OK" \ No newline at end of file diff --git a/packages/crystal/0.36.1/build.sh b/packages/crystal/1.9.2/build.sh old mode 100755 new mode 100644 similarity index 72% rename from packages/crystal/0.36.1/build.sh rename to packages/crystal/1.9.2/build.sh index ba10f3f..e95779c --- a/packages/crystal/0.36.1/build.sh +++ b/packages/crystal/1.9.2/build.sh @@ -2,6 +2,6 @@ PREFIX=$(realpath $(dirname $0)) -curl -L "https://github.com/crystal-lang/crystal/releases/download/0.36.1/crystal-0.36.1-1-linux-x86_64.tar.gz" -o crystal.tar.gz +curl -L "https://github.com/crystal-lang/crystal/releases/download/1.9.2/crystal-1.9.2-1-linux-x86_64.tar.gz" -o crystal.tar.gz tar xzf crystal.tar.gz --strip-components=1 rm crystal.tar.gz diff --git a/packages/crystal/0.36.1/compile b/packages/crystal/1.9.2/compile similarity index 100% rename from packages/crystal/0.36.1/compile rename to packages/crystal/1.9.2/compile diff --git a/packages/crystal/0.36.1/environment b/packages/crystal/1.9.2/environment similarity index 100% rename from packages/crystal/0.36.1/environment rename to packages/crystal/1.9.2/environment diff --git a/packages/crystal/0.36.1/metadata.json b/packages/crystal/1.9.2/metadata.json similarity index 71% rename from packages/crystal/0.36.1/metadata.json rename to packages/crystal/1.9.2/metadata.json index ee995eb..09a23ad 100644 --- a/packages/crystal/0.36.1/metadata.json +++ b/packages/crystal/1.9.2/metadata.json @@ -1,5 +1,5 @@ { "language": "crystal", - "version": "0.36.1", + "version": "1.9.2", "aliases": ["crystal", "cr"] } diff --git a/packages/crystal/0.36.1/run b/packages/crystal/1.9.2/run similarity index 100% rename from packages/crystal/0.36.1/run rename to packages/crystal/1.9.2/run diff --git a/packages/crystal/0.36.1/test.cr b/packages/crystal/1.9.2/test.cr similarity index 100% rename from packages/crystal/0.36.1/test.cr rename to packages/crystal/1.9.2/test.cr diff --git a/packages/dart/2.19.6/build.sh b/packages/dart/2.19.6/build.sh new file mode 100644 index 0000000..ec04ab1 --- /dev/null +++ b/packages/dart/2.19.6/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +curl -L "https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.6/sdk/dartsdk-linux-x64-release.zip" -o dart.zip + +unzip dart.zip +rm dart.zip + +cp -r dart-sdk/* . +rm -rf dart-sdk + +chmod -R +rx bin \ No newline at end of file diff --git a/packages/dart/2.19.6/environment b/packages/dart/2.19.6/environment new file mode 100644 index 0000000..c6ab089 --- /dev/null +++ b/packages/dart/2.19.6/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/dart/2.19.6/metadata.json b/packages/dart/2.19.6/metadata.json new file mode 100644 index 0000000..ab0c1a2 --- /dev/null +++ b/packages/dart/2.19.6/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "dart", + "version": "2.19.6", + "aliases": [] +} \ No newline at end of file diff --git a/packages/dart/2.19.6/run b/packages/dart/2.19.6/run new file mode 100644 index 0000000..062d7c6 --- /dev/null +++ b/packages/dart/2.19.6/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put instructions to run the runtime +dart run "$@" \ No newline at end of file diff --git a/packages/dart/2.19.6/test.dart b/packages/dart/2.19.6/test.dart new file mode 100644 index 0000000..27e87b2 --- /dev/null +++ b/packages/dart/2.19.6/test.dart @@ -0,0 +1,3 @@ +void main() { + print('OK'); +} \ No newline at end of file diff --git a/packages/dart/3.0.1/build.sh b/packages/dart/3.0.1/build.sh new file mode 100755 index 0000000..02e9f7e --- /dev/null +++ b/packages/dart/3.0.1/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +curl -L "https://storage.googleapis.com/dart-archive/channels/stable/release/3.0.1/sdk/dartsdk-linux-x64-release.zip" -o dart.zip + +unzip dart.zip +rm dart.zip + +cp -r dart-sdk/* . +rm -rf dart-sdk + +chmod -R +rx bin \ No newline at end of file diff --git a/packages/dart/3.0.1/environment b/packages/dart/3.0.1/environment new file mode 100644 index 0000000..c6ab089 --- /dev/null +++ b/packages/dart/3.0.1/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/dart/3.0.1/metadata.json b/packages/dart/3.0.1/metadata.json new file mode 100644 index 0000000..afc3ae2 --- /dev/null +++ b/packages/dart/3.0.1/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "dart", + "version": "3.0.1", + "aliases": [] +} \ No newline at end of file diff --git a/packages/dart/3.0.1/run b/packages/dart/3.0.1/run new file mode 100644 index 0000000..062d7c6 --- /dev/null +++ b/packages/dart/3.0.1/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put instructions to run the runtime +dart run "$@" \ No newline at end of file diff --git a/packages/dart/3.0.1/test.dart b/packages/dart/3.0.1/test.dart new file mode 100644 index 0000000..27e87b2 --- /dev/null +++ b/packages/dart/3.0.1/test.dart @@ -0,0 +1,3 @@ +void main() { + print('OK'); +} \ No newline at end of file diff --git a/packages/deno/1.16.2/run b/packages/deno/1.16.2/run index 288919f..530181f 100644 --- a/packages/deno/1.16.2/run +++ b/packages/deno/1.16.2/run @@ -1,3 +1,3 @@ #!/bin/bash -DENO_DIR=$PWD deno run $@ +DENO_DIR=$PWD NO_COLOR=true deno run $@ diff --git a/packages/deno/1.32.3/build.sh b/packages/deno/1.32.3/build.sh new file mode 100644 index 0000000..8cda9bc --- /dev/null +++ b/packages/deno/1.32.3/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +curl -OL https://github.com/denoland/deno/releases/download/v1.32.3/deno-x86_64-unknown-linux-gnu.zip +unzip -o deno-x86_64-unknown-linux-gnu.zip +rm deno-x86_64-unknown-linux-gnu.zip \ No newline at end of file diff --git a/packages/deno/1.32.3/environment b/packages/deno/1.32.3/environment new file mode 100644 index 0000000..0d5a1f7 --- /dev/null +++ b/packages/deno/1.32.3/environment @@ -0,0 +1,3 @@ +#!/bin/bash + +export PATH=$PWD:$PATH \ No newline at end of file diff --git a/packages/deno/1.32.3/metadata.json b/packages/deno/1.32.3/metadata.json new file mode 100644 index 0000000..2dc0a7c --- /dev/null +++ b/packages/deno/1.32.3/metadata.json @@ -0,0 +1,20 @@ +{ + "language": "deno", + "version": "1.32.3", + "dependencies": {}, + "provides": [ + { + "language": "typescript", + "aliases": [ + "deno", + "deno-ts" + ] + }, + { + "language": "javascript", + "aliases": [ + "deno-js" + ] + } + ] +} \ No newline at end of file diff --git a/packages/deno/1.32.3/run b/packages/deno/1.32.3/run new file mode 100644 index 0000000..5c9cfb6 --- /dev/null +++ b/packages/deno/1.32.3/run @@ -0,0 +1,3 @@ +#!/bin/bash + +DENO_DIR=$PWD NO_COLOR=true deno run $@ \ No newline at end of file diff --git a/packages/deno/1.32.3/test.deno.ts b/packages/deno/1.32.3/test.deno.ts new file mode 100644 index 0000000..56ed4a0 --- /dev/null +++ b/packages/deno/1.32.3/test.deno.ts @@ -0,0 +1 @@ +console.log("OK") \ No newline at end of file diff --git a/packages/deno/1.7.5/run b/packages/deno/1.7.5/run index d1b196f..fbbe106 100644 --- a/packages/deno/1.7.5/run +++ b/packages/deno/1.7.5/run @@ -1,2 +1,2 @@ #!/bin/bash -DENO_DIR=$PWD deno run "$@" \ No newline at end of file +DENO_DIR=$PWD NO_COLOR=true deno run "$@" \ No newline at end of file diff --git a/packages/freebasic/1.9.0/build.sh b/packages/freebasic/1.9.0/build.sh new file mode 100644 index 0000000..7f33fff --- /dev/null +++ b/packages/freebasic/1.9.0/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +curl -L "https://sourceforge.net/projects/fbc/files/FreeBASIC-1.09.0/Binaries-Linux/FreeBASIC-1.09.0-linux-x86_64.tar.gz/download" -o freebasic.tar.gz +tar xf freebasic.tar.gz --strip-components=1 +rm freebasic.tar.gz \ No newline at end of file diff --git a/packages/freebasic/1.9.0/compile b/packages/freebasic/1.9.0/compile new file mode 100644 index 0000000..20842d6 --- /dev/null +++ b/packages/freebasic/1.9.0/compile @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Compile bas files +fbc -lang qb -b "$@" -x out \ No newline at end of file diff --git a/packages/freebasic/1.9.0/environment b/packages/freebasic/1.9.0/environment new file mode 100644 index 0000000..8064d82 --- /dev/null +++ b/packages/freebasic/1.9.0/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Path to fbc compiler +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/freebasic/1.9.0/metadata.json b/packages/freebasic/1.9.0/metadata.json new file mode 100644 index 0000000..d0c3eb9 --- /dev/null +++ b/packages/freebasic/1.9.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "freebasic", + "version": "1.9.0", + "aliases": ["bas", "fbc", "basic", "qbasic", "quickbasic"] +} \ No newline at end of file diff --git a/packages/freebasic/1.9.0/run b/packages/freebasic/1.9.0/run new file mode 100644 index 0000000..6f7b53d --- /dev/null +++ b/packages/freebasic/1.9.0/run @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Run output file from compile with arguments +shift +./out "$@" \ No newline at end of file diff --git a/packages/freebasic/1.9.0/test.bas b/packages/freebasic/1.9.0/test.bas new file mode 100644 index 0000000..b13a0ef --- /dev/null +++ b/packages/freebasic/1.9.0/test.bas @@ -0,0 +1 @@ +PRINT "OK" \ No newline at end of file diff --git a/packages/julia/1.8.5/build.sh b/packages/julia/1.8.5/build.sh new file mode 100644 index 0000000..752d902 --- /dev/null +++ b/packages/julia/1.8.5/build.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Install location +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build +cd build + +# Download and extract Julia source +curl -L "https://github.com/JuliaLang/julia/releases/download/v1.8.5/julia-1.8.5.tar.gz" -o julia.tar.gz +tar xzf julia.tar.gz --strip-components=1 + +# Build +echo "JULIA_CPU_TARGET=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1) +prefix=$PREFIX" > Make.user +make -j$(nproc) +make install -j$(nproc) + +# Cleanup +cd .. +rm -rf build \ No newline at end of file diff --git a/packages/julia/1.8.5/environment b/packages/julia/1.8.5/environment new file mode 100644 index 0000000..7eadd1a --- /dev/null +++ b/packages/julia/1.8.5/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Add Julia binary to path +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/julia/1.8.5/metadata.json b/packages/julia/1.8.5/metadata.json new file mode 100644 index 0000000..5c6fd40 --- /dev/null +++ b/packages/julia/1.8.5/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "julia", + "version": "1.8.5", + "aliases": ["jl"] +} \ No newline at end of file diff --git a/packages/julia/1.8.5/run b/packages/julia/1.8.5/run new file mode 100644 index 0000000..a803c0a --- /dev/null +++ b/packages/julia/1.8.5/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Run without startup or history file +julia --startup-file=no --history-file=no "$@" \ No newline at end of file diff --git a/packages/julia/1.8.5/test.jl b/packages/julia/1.8.5/test.jl new file mode 100644 index 0000000..450f23e --- /dev/null +++ b/packages/julia/1.8.5/test.jl @@ -0,0 +1 @@ +println("OK") \ No newline at end of file diff --git a/packages/k/1.0.0/build.sh b/packages/k/1.0.0/build.sh new file mode 100644 index 0000000..567cc06 --- /dev/null +++ b/packages/k/1.0.0/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +git clone "https://codeberg.org/ngn/k" k +cd k + +git checkout 544d014afd8dd84b18c2011cabd3aa3d76571ca3 +make CC=gcc diff --git a/packages/k/1.0.0/environment b/packages/k/1.0.0/environment new file mode 100644 index 0000000..7cde4ae --- /dev/null +++ b/packages/k/1.0.0/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# k path +export PATH=$PWD/bin:$PATH +export K_PATH=$PWD/k diff --git a/packages/k/1.0.0/metadata.json b/packages/k/1.0.0/metadata.json new file mode 100644 index 0000000..3a557f6 --- /dev/null +++ b/packages/k/1.0.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "k", + "version": "1.0.0", + "aliases": ["ngnk"] +} diff --git a/packages/k/1.0.0/run b/packages/k/1.0.0/run new file mode 100644 index 0000000..18293ae --- /dev/null +++ b/packages/k/1.0.0/run @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +$K_PATH/k "$@" diff --git a/packages/k/1.0.0/test.k b/packages/k/1.0.0/test.k new file mode 100644 index 0000000..16fddca --- /dev/null +++ b/packages/k/1.0.0/test.k @@ -0,0 +1 @@ +`0:`c$2/'((1 0 0 1 1 1 1);(1 0 0 1 0 1 1)) diff --git a/packages/kotlin/1.8.20/build.sh b/packages/kotlin/1.8.20/build.sh new file mode 100644 index 0000000..2574b8d --- /dev/null +++ b/packages/kotlin/1.8.20/build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Download and extract JDK8 +curl -L "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz" -o jdk.tar.gz +tar xzf jdk.tar.gz --strip-components=1 +rm jdk.tar.gz + +# Download and extract Kotlin +curl -L "https://github.com/JetBrains/kotlin/releases/download/v1.8.20/kotlin-compiler-1.8.20.zip" -o kotlin.zip +unzip kotlin.zip +rm kotlin.zip +cp -r kotlinc/* . +rm -rf kotlinc \ No newline at end of file diff --git a/packages/kotlin/1.8.20/compile b/packages/kotlin/1.8.20/compile new file mode 100644 index 0000000..7ef1cff --- /dev/null +++ b/packages/kotlin/1.8.20/compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +rename 's/$/\.kt/' "$@" # Add .kt extension + +# Compile Kotlin code to a jar file +kotlinc *.kt -include-runtime -d code.jar \ No newline at end of file diff --git a/packages/kotlin/1.8.20/environment b/packages/kotlin/1.8.20/environment new file mode 100644 index 0000000..9f25b86 --- /dev/null +++ b/packages/kotlin/1.8.20/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Add java and kotlinc to path +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/kotlin/1.8.20/metadata.json b/packages/kotlin/1.8.20/metadata.json new file mode 100644 index 0000000..7a4321e --- /dev/null +++ b/packages/kotlin/1.8.20/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "kotlin", + "version": "1.8.20", + "aliases": ["kt"] +} \ No newline at end of file diff --git a/packages/kotlin/1.8.20/run b/packages/kotlin/1.8.20/run new file mode 100644 index 0000000..a719220 --- /dev/null +++ b/packages/kotlin/1.8.20/run @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Run jar file +shift +java -jar code.jar "$@" \ No newline at end of file diff --git a/packages/kotlin/1.8.20/test.kt b/packages/kotlin/1.8.20/test.kt new file mode 100644 index 0000000..31acf7b --- /dev/null +++ b/packages/kotlin/1.8.20/test.kt @@ -0,0 +1,3 @@ +fun main() { + println("OK") +} \ No newline at end of file diff --git a/packages/lua/5.4.4/build.sh b/packages/lua/5.4.4/build.sh new file mode 100644 index 0000000..979fefe --- /dev/null +++ b/packages/lua/5.4.4/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Put instructions to build your package in here +curl -R -O -L http://www.lua.org/ftp/lua-5.4.4.tar.gz +tar zxf lua-5.4.4.tar.gz +rm lua-5.4.4.tar.gz + +cd lua-5.4.4 +# Building Lua +make linux +# To check that Lua has been built correctly +make test +# Installing Lua +make linux install \ No newline at end of file diff --git a/packages/lua/5.4.4/environment b/packages/lua/5.4.4/environment new file mode 100644 index 0000000..db702d4 --- /dev/null +++ b/packages/lua/5.4.4/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH="$PWD/lua-5.4.4/src:$PATH" \ No newline at end of file diff --git a/packages/lua/5.4.4/metadata.json b/packages/lua/5.4.4/metadata.json new file mode 100644 index 0000000..a2a51b7 --- /dev/null +++ b/packages/lua/5.4.4/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "lua", + "version": "5.4.4", + "aliases": [] +} \ No newline at end of file diff --git a/packages/lua/5.4.4/run b/packages/lua/5.4.4/run new file mode 100644 index 0000000..d826943 --- /dev/null +++ b/packages/lua/5.4.4/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put instructions to run the runtime +lua "$@" \ No newline at end of file diff --git a/packages/lua/5.4.4/test.lua b/packages/lua/5.4.4/test.lua new file mode 100644 index 0000000..3f2688f --- /dev/null +++ b/packages/lua/5.4.4/test.lua @@ -0,0 +1 @@ +print("OK") \ No newline at end of file diff --git a/packages/mono/6.12.0/build.sh b/packages/mono/6.12.0/build.sh index 7bb4b63..d74fca6 100755 --- a/packages/mono/6.12.0/build.sh +++ b/packages/mono/6.12.0/build.sh @@ -5,7 +5,7 @@ PREFIX=$(realpath $(dirname $0)) mkdir -p build/mono build/mono-basic cd build -curl "https://download.mono-project.com/sources/mono/mono-6.12.0.122.tar.xz" -o mono.tar.xz +curl "https://download.mono-project.com/sources/mono/mono-6.12.0.182.tar.xz" -o mono.tar.xz curl -L "https://github.com/mono/mono-basic/archive/refs/tags/4.7.tar.gz" -o mono-basic.tar.gz tar xf mono.tar.xz --strip-components=1 -C mono tar xf mono-basic.tar.gz --strip-components=1 -C mono-basic diff --git a/packages/nim/1.6.2/build.sh b/packages/nim/1.6.2/build.sh new file mode 100644 index 0000000..20a9b65 --- /dev/null +++ b/packages/nim/1.6.2/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build + +# Prebuilt binary - source *can* be built, but it requires gcc +curl -L "https://nim-lang.org/download/nim-1.6.2-linux_x64.tar.xz" -o nim.tar.xz +tar xf nim.tar.xz --strip-components=1 +rm nim.tar.xz + +./install.sh "$PREFIX" + +cd ../ + +rm -rf build \ No newline at end of file diff --git a/packages/nim/1.6.2/compile b/packages/nim/1.6.2/compile new file mode 100644 index 0000000..1162cb3 --- /dev/null +++ b/packages/nim/1.6.2/compile @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Compile nim file(s) +nim --hints:off --out:out --nimcache:./ c "$@" +chmod +x out \ No newline at end of file diff --git a/packages/nim/1.6.2/environment b/packages/nim/1.6.2/environment new file mode 100644 index 0000000..872a1f3 --- /dev/null +++ b/packages/nim/1.6.2/environment @@ -0,0 +1 @@ +export PATH=$PWD/nim/bin:$PATH \ No newline at end of file diff --git a/packages/nim/1.6.2/metadata.json b/packages/nim/1.6.2/metadata.json new file mode 100644 index 0000000..facb421 --- /dev/null +++ b/packages/nim/1.6.2/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "nim", + "version": "1.6.2", + "aliases": [] +} \ No newline at end of file diff --git a/packages/nim/1.6.2/run b/packages/nim/1.6.2/run new file mode 100644 index 0000000..eb7e9c3 --- /dev/null +++ b/packages/nim/1.6.2/run @@ -0,0 +1,4 @@ +#!/bin/bash + +shift # Filename is only used to compile +./out "$@" \ No newline at end of file diff --git a/packages/nim/1.6.2/test.nim b/packages/nim/1.6.2/test.nim new file mode 100644 index 0000000..6c57628 --- /dev/null +++ b/packages/nim/1.6.2/test.nim @@ -0,0 +1 @@ +echo("OK") \ No newline at end of file diff --git a/packages/node/18.15.0/build.sh b/packages/node/18.15.0/build.sh new file mode 100644 index 0000000..08da779 --- /dev/null +++ b/packages/node/18.15.0/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +curl "https://nodejs.org/dist/v18.15.0/node-v18.15.0-linux-x64.tar.xz" -o node.tar.xz +tar xf node.tar.xz --strip-components=1 +rm node.tar.xz \ No newline at end of file diff --git a/packages/node/18.15.0/environment b/packages/node/18.15.0/environment new file mode 100644 index 0000000..bd0ff98 --- /dev/null +++ b/packages/node/18.15.0/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/node/18.15.0/metadata.json b/packages/node/18.15.0/metadata.json new file mode 100644 index 0000000..7dcc24d --- /dev/null +++ b/packages/node/18.15.0/metadata.json @@ -0,0 +1,10 @@ +{ + "language": "node", + "version": "18.15.0", + "provides": [ + { + "language": "javascript", + "aliases": ["node-javascript", "node-js", "javascript", "js"] + } + ] +} \ No newline at end of file diff --git a/packages/node/18.15.0/run b/packages/node/18.15.0/run new file mode 100644 index 0000000..6d1fdee --- /dev/null +++ b/packages/node/18.15.0/run @@ -0,0 +1,3 @@ +#!/bin/bash + +node "$@" \ No newline at end of file diff --git a/packages/node/18.15.0/test.js b/packages/node/18.15.0/test.js new file mode 100644 index 0000000..c963843 --- /dev/null +++ b/packages/node/18.15.0/test.js @@ -0,0 +1 @@ +console.log('OK'); \ No newline at end of file diff --git a/packages/node/20.11.1/build.sh b/packages/node/20.11.1/build.sh new file mode 100644 index 0000000..4c7a3af --- /dev/null +++ b/packages/node/20.11.1/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +curl "https://nodejs.org/dist/v20.11.1/node-v20.11.1-linux-x64.tar.xz" -o node.tar.xz +tar xf node.tar.xz --strip-components=1 +rm node.tar.xz \ No newline at end of file diff --git a/packages/node/20.11.1/environment b/packages/node/20.11.1/environment new file mode 100644 index 0000000..bd0ff98 --- /dev/null +++ b/packages/node/20.11.1/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/node/20.11.1/metadata.json b/packages/node/20.11.1/metadata.json new file mode 100644 index 0000000..d401ad5 --- /dev/null +++ b/packages/node/20.11.1/metadata.json @@ -0,0 +1,10 @@ +{ + "language": "node", + "version": "20.11.1", + "provides": [ + { + "language": "javascript", + "aliases": ["node-javascript", "node-js", "javascript", "js"] + } + ] +} \ No newline at end of file diff --git a/packages/node/20.11.1/run b/packages/node/20.11.1/run new file mode 100644 index 0000000..6d1fdee --- /dev/null +++ b/packages/node/20.11.1/run @@ -0,0 +1,3 @@ +#!/bin/bash + +node "$@" \ No newline at end of file diff --git a/packages/node/20.11.1/test.js b/packages/node/20.11.1/test.js new file mode 100644 index 0000000..c963843 --- /dev/null +++ b/packages/node/20.11.1/test.js @@ -0,0 +1 @@ +console.log('OK'); \ No newline at end of file diff --git a/packages/octave/8.1.0/build.sh b/packages/octave/8.1.0/build.sh new file mode 100644 index 0000000..f835f2e --- /dev/null +++ b/packages/octave/8.1.0/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Build octave from source +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build + +curl -L "https://ftpmirror.gnu.org/octave/octave-8.1.0.tar.gz" -o octave.tar.gz + +tar xzf octave.tar.gz --strip-components=1 + +# === autoconf based === +# Disable support for GUI, HDF5 and Java +./configure --prefix "$PREFIX" --without-opengl --without-qt --without-x --without-hdf5 --disable-java + +make -j$(nproc) +make install -j$(nproc) + +cd ../ +rm -rf build \ No newline at end of file diff --git a/packages/octave/8.1.0/environment b/packages/octave/8.1.0/environment new file mode 100644 index 0000000..6eb8659 --- /dev/null +++ b/packages/octave/8.1.0/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Path to octave binary +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/octave/8.1.0/metadata.json b/packages/octave/8.1.0/metadata.json new file mode 100644 index 0000000..9e0023d --- /dev/null +++ b/packages/octave/8.1.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "octave", + "version": "8.1.0", + "aliases": ["matlab", "m"] +} \ No newline at end of file diff --git a/packages/octave/8.1.0/run b/packages/octave/8.1.0/run new file mode 100644 index 0000000..42cf092 --- /dev/null +++ b/packages/octave/8.1.0/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Run octave scripts without gui, history, init scripts and initial message +octave --no-gui --no-window-system --no-history --no-init-file --no-site-file --norc --quiet "$@" \ No newline at end of file diff --git a/packages/octave/8.1.0/test.octave b/packages/octave/8.1.0/test.octave new file mode 100644 index 0000000..a94310b --- /dev/null +++ b/packages/octave/8.1.0/test.octave @@ -0,0 +1 @@ +disp('OK') \ No newline at end of file diff --git a/packages/pascal/3.2.2/build.sh b/packages/pascal/3.2.2/build.sh new file mode 100644 index 0000000..aa4ad60 --- /dev/null +++ b/packages/pascal/3.2.2/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build +curl -L "https://sourceforge.net/projects/freepascal/files/Linux/3.2.2/fpc-3.2.2.x86_64-linux.tar/download" -o pascal.tar +tar xf pascal.tar --strip-components=1 + +# FreePascal uses an interactive installer +./install.sh << ANSWERS +$PREFIX +n +n +n +ANSWERS + +cd .. +rm -rf build + +# A sample config (needed for each "project") is written to /etc +# We'll copy that into the local lib dir (fpc searches there too on compile) +mkdir lib/fpc/etc +cp -r /etc/fp* lib/fpc/etc/ \ No newline at end of file diff --git a/packages/pascal/3.2.2/compile b/packages/pascal/3.2.2/compile new file mode 100644 index 0000000..20b1280 --- /dev/null +++ b/packages/pascal/3.2.2/compile @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Compile pascal files +fpc -oout -v0 "$@" +chmod +x out \ No newline at end of file diff --git a/packages/pascal/3.2.2/environment b/packages/pascal/3.2.2/environment new file mode 100644 index 0000000..bd0ff98 --- /dev/null +++ b/packages/pascal/3.2.2/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/pascal/3.2.2/metadata.json b/packages/pascal/3.2.2/metadata.json new file mode 100644 index 0000000..cd85425 --- /dev/null +++ b/packages/pascal/3.2.2/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "pascal", + "version": "3.2.2", + "aliases": ["freepascal", "pp", "pas"] +} \ No newline at end of file diff --git a/packages/pascal/3.2.2/run b/packages/pascal/3.2.2/run new file mode 100644 index 0000000..eb7e9c3 --- /dev/null +++ b/packages/pascal/3.2.2/run @@ -0,0 +1,4 @@ +#!/bin/bash + +shift # Filename is only used to compile +./out "$@" \ No newline at end of file diff --git a/packages/pascal/3.2.2/test.pp b/packages/pascal/3.2.2/test.pp new file mode 100644 index 0000000..3c5165d --- /dev/null +++ b/packages/pascal/3.2.2/test.pp @@ -0,0 +1,5 @@ +program test; + + begin + writeln('OK'); + end. \ No newline at end of file diff --git a/packages/perl/5.36.0/build.sh b/packages/perl/5.36.0/build.sh new file mode 100644 index 0000000..a5aeacb --- /dev/null +++ b/packages/perl/5.36.0/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build + +curl "https://www.cpan.org/src/5.0/perl-5.36.0.tar.gz" -o perl.tar.gz +tar xzf perl.tar.gz --strip-components=1 +./Configure -des -Dprefix="$PREFIX" + +make -j$(nproc) +make install -j$(nproc) + +cd .. + +rm -rf build \ No newline at end of file diff --git a/packages/perl/5.36.0/environment b/packages/perl/5.36.0/environment new file mode 100644 index 0000000..bd0ff98 --- /dev/null +++ b/packages/perl/5.36.0/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/perl/5.36.0/metadata.json b/packages/perl/5.36.0/metadata.json new file mode 100644 index 0000000..3e30158 --- /dev/null +++ b/packages/perl/5.36.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "perl", + "version": "5.36.0", + "aliases": ["pl"] +} \ No newline at end of file diff --git a/packages/perl/5.36.0/run b/packages/perl/5.36.0/run new file mode 100644 index 0000000..3b8d77c --- /dev/null +++ b/packages/perl/5.36.0/run @@ -0,0 +1,3 @@ +#!/bin/bash + +perl "$@" \ No newline at end of file diff --git a/packages/perl/5.36.0/test.pl b/packages/perl/5.36.0/test.pl new file mode 100644 index 0000000..3f2688f --- /dev/null +++ b/packages/perl/5.36.0/test.pl @@ -0,0 +1 @@ +print("OK") \ No newline at end of file diff --git a/packages/php/8.2.3/build.sh b/packages/php/8.2.3/build.sh new file mode 100644 index 0000000..ee85017 --- /dev/null +++ b/packages/php/8.2.3/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build/php +cd build + +curl "https://www.php.net/distributions/php-8.2.3.tar.gz" -o php.tar.gz +tar xzf php.tar.gz --strip-components=1 -C php + +cd php + + +./configure --prefix "$PREFIX" + +make -j$(nproc) +make install -j$(nproc) + +cd ../../ +rm -rf build \ No newline at end of file diff --git a/packages/php/8.2.3/environment b/packages/php/8.2.3/environment new file mode 100644 index 0000000..bd0ff98 --- /dev/null +++ b/packages/php/8.2.3/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/php/8.2.3/metadata.json b/packages/php/8.2.3/metadata.json new file mode 100644 index 0000000..5f256e0 --- /dev/null +++ b/packages/php/8.2.3/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "php", + "version": "8.2.3", + "aliases": [] +} \ No newline at end of file diff --git a/packages/php/8.2.3/run b/packages/php/8.2.3/run new file mode 100644 index 0000000..1261d95 --- /dev/null +++ b/packages/php/8.2.3/run @@ -0,0 +1,3 @@ +#!/bin/bash + +php "$@" \ No newline at end of file diff --git a/packages/php/8.2.3/test.php b/packages/php/8.2.3/test.php new file mode 100644 index 0000000..a0aba93 --- /dev/null +++ b/packages/php/8.2.3/test.php @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/packages/python/3.10.0/build.sh b/packages/python/3.10.0/build.sh index 00c839a..62fef92 100755 --- a/packages/python/3.10.0/build.sh +++ b/packages/python/3.10.0/build.sh @@ -18,4 +18,4 @@ cd .. rm -rf build -bin/pip3 install numpy scipy pandas pycrypto whoosh bcrypt passlib sympy +bin/pip3 install numpy scipy pandas pycrypto whoosh bcrypt passlib sympy xxhash base58 cryptography PyNaCl diff --git a/packages/python/3.11.0/build.sh b/packages/python/3.11.0/build.sh new file mode 100644 index 0000000..8db680c --- /dev/null +++ b/packages/python/3.11.0/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build + +curl "https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz" -o python.tar.gz +tar xzf python.tar.gz --strip-components=1 +rm python.tar.gz + +./configure --prefix "$PREFIX" --with-ensurepip=install +make -j$(nproc) +make install -j$(nproc) + +cd .. + +rm -rf build + +bin/pip3 install numpy scipy pandas pycryptodome whoosh bcrypt passlib sympy xxhash base58 cryptography PyNaCl diff --git a/packages/python/3.11.0/environment b/packages/python/3.11.0/environment new file mode 100644 index 0000000..977a5e8 --- /dev/null +++ b/packages/python/3.11.0/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH diff --git a/packages/python/3.11.0/metadata.json b/packages/python/3.11.0/metadata.json new file mode 100644 index 0000000..c169a60 --- /dev/null +++ b/packages/python/3.11.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "python", + "version": "3.11.0", + "aliases": ["py", "py3", "python3", "python3.11"] +} diff --git a/packages/python/3.11.0/run b/packages/python/3.11.0/run new file mode 100644 index 0000000..cf38089 --- /dev/null +++ b/packages/python/3.11.0/run @@ -0,0 +1,3 @@ +#!/bin/bash + +python3.11 "$@" diff --git a/packages/python/3.11.0/test.py b/packages/python/3.11.0/test.py new file mode 100644 index 0000000..1784bfa --- /dev/null +++ b/packages/python/3.11.0/test.py @@ -0,0 +1,7 @@ +working = True + +match working: + case True: + print("OK") + case False: + print() diff --git a/packages/python/3.12.0/build.sh b/packages/python/3.12.0/build.sh new file mode 100644 index 0000000..4de24a7 --- /dev/null +++ b/packages/python/3.12.0/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +PREFIX=$(realpath $(dirname $0)) + +mkdir -p build + +cd build + +curl "https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz" -o python.tar.gz +tar xzf python.tar.gz --strip-components=1 +rm python.tar.gz + +./configure --prefix "$PREFIX" --with-ensurepip=install +make -j$(nproc) +make install -j$(nproc) + +cd .. + +rm -rf build + +bin/pip3 install numpy scipy pandas pycryptodome whoosh bcrypt passlib sympy xxhash base58 cryptography PyNaCl diff --git a/packages/python/3.12.0/environment b/packages/python/3.12.0/environment new file mode 100644 index 0000000..977a5e8 --- /dev/null +++ b/packages/python/3.12.0/environment @@ -0,0 +1 @@ +export PATH=$PWD/bin:$PATH diff --git a/packages/python/3.12.0/metadata.json b/packages/python/3.12.0/metadata.json new file mode 100644 index 0000000..59d257a --- /dev/null +++ b/packages/python/3.12.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "python", + "version": "3.12.0", + "aliases": ["py", "py3", "python3", "python3.12"] +} diff --git a/packages/python/3.12.0/run b/packages/python/3.12.0/run new file mode 100644 index 0000000..6f77990 --- /dev/null +++ b/packages/python/3.12.0/run @@ -0,0 +1,3 @@ +#!/bin/bash + +python3.12 "$@" diff --git a/packages/python/3.12.0/test.py b/packages/python/3.12.0/test.py new file mode 100644 index 0000000..1784bfa --- /dev/null +++ b/packages/python/3.12.0/test.py @@ -0,0 +1,7 @@ +working = True + +match working: + case True: + print("OK") + case False: + print() diff --git a/packages/rust/1.68.2/build.sh b/packages/rust/1.68.2/build.sh new file mode 100644 index 0000000..bfd853f --- /dev/null +++ b/packages/rust/1.68.2/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +curl -OL "https://static.rust-lang.org/dist/rust-1.68.2-x86_64-unknown-linux-gnu.tar.gz" +tar xzvf rust-1.68.2-x86_64-unknown-linux-gnu.tar.gz +rm rust-1.68.2-x86_64-unknown-linux-gnu.tar.gz \ No newline at end of file diff --git a/packages/rust/1.68.2/compile b/packages/rust/1.68.2/compile new file mode 100644 index 0000000..c4b591a --- /dev/null +++ b/packages/rust/1.68.2/compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std +# Rust compiler needs to find the stdlib to link against +rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@" +chmod +x binary \ No newline at end of file diff --git a/packages/rust/1.68.2/environment b/packages/rust/1.68.2/environment new file mode 100644 index 0000000..77e21a4 --- /dev/null +++ b/packages/rust/1.68.2/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/rust-1.68.2-x86_64-unknown-linux-gnu/rustc/bin/:$PATH +export RUST_INSTALL_LOC=$PWD/rust-1.68.2-x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/packages/rust/1.68.2/metadata.json b/packages/rust/1.68.2/metadata.json new file mode 100644 index 0000000..e0cdb7c --- /dev/null +++ b/packages/rust/1.68.2/metadata.json @@ -0,0 +1,7 @@ +{ + "language": "rust", + "version": "1.68.2", + "aliases": [ + "rs" + ] +} \ No newline at end of file diff --git a/packages/rust/1.68.2/run b/packages/rust/1.68.2/run new file mode 100644 index 0000000..bb85070 --- /dev/null +++ b/packages/rust/1.68.2/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +shift +./binary "$@" \ No newline at end of file diff --git a/packages/rust/1.68.2/test.rs b/packages/rust/1.68.2/test.rs new file mode 100644 index 0000000..f5524c7 --- /dev/null +++ b/packages/rust/1.68.2/test.rs @@ -0,0 +1,3 @@ +fn main() { + println!("OK"); +} \ No newline at end of file diff --git a/packages/samarium/0.3.1/build.sh b/packages/samarium/0.3.1/build.sh new file mode 100755 index 0000000..b0f6ea0 --- /dev/null +++ b/packages/samarium/0.3.1/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source ../../python/3.10.0/build.sh +bin/pip3 install https://github.com/samarium-lang/Samarium/archive/refs/tags/0.3.1.zip diff --git a/packages/samarium/0.3.1/environment b/packages/samarium/0.3.1/environment new file mode 100644 index 0000000..b482830 --- /dev/null +++ b/packages/samarium/0.3.1/environment @@ -0,0 +1,2 @@ +#!/bin/bash +export PATH=$PWD/bin:$PATH diff --git a/packages/samarium/0.3.1/metadata.json b/packages/samarium/0.3.1/metadata.json new file mode 100644 index 0000000..9f3b810 --- /dev/null +++ b/packages/samarium/0.3.1/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "samarium", + "version": "0.3.1", + "aliases": ["sm"] +} diff --git a/packages/samarium/0.3.1/run b/packages/samarium/0.3.1/run new file mode 100644 index 0000000..d65533d --- /dev/null +++ b/packages/samarium/0.3.1/run @@ -0,0 +1 @@ +python3 -m samarium $1 diff --git a/packages/samarium/0.3.1/test.sm b/packages/samarium/0.3.1/test.sm new file mode 100644 index 0000000..57d4d5c --- /dev/null +++ b/packages/samarium/0.3.1/test.sm @@ -0,0 +1,3 @@ +=> * { + "OK"!; +} diff --git a/packages/scala/3.2.2/build.sh b/packages/scala/3.2.2/build.sh new file mode 100644 index 0000000..2feef19 --- /dev/null +++ b/packages/scala/3.2.2/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Download and extract JDK8 +curl -L "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u292b10.tar.gz" -o jdk.tar.gz +tar xzf jdk.tar.gz --strip-components=1 +rm jdk.tar.gz + +# Download and extract Scala 3 +curl -L "https://github.com/lampepfl/dotty/releases/download/3.2.2/scala3-3.2.2.tar.gz" -o scala.tar.gz +tar -xzf scala.tar.gz --strip-components=1 +rm scala.tar.gz \ No newline at end of file diff --git a/packages/scala/3.2.2/compile b/packages/scala/3.2.2/compile new file mode 100644 index 0000000..4d9cf66 --- /dev/null +++ b/packages/scala/3.2.2/compile @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Compile scala classes into a jar file +scalac "$@" -d out.jar + +# Create the Manifest and include scala lib jars: +# NOTE: - entry point will only consider @main and App traits from the main file +# - scala lib jars will be added to the class path in order to run the jar properly +echo "Main-Class: $(grep -oP '\@main\s+def\s+\K[a-zA-Z][a-zA-Z0-9]*|object\s+\K[a-zA-Z][a-zA-Z0-9]*(?=\s+extends\s+App)' $1) +Class-Path: $(echo $JAVA_HOME/lib/*.jar | sed 's/\s/\n /g') +" > manifest.txt + +# Update the jar with the manifest +jar ufm out.jar manifest.txt \ No newline at end of file diff --git a/packages/scala/3.2.2/environment b/packages/scala/3.2.2/environment new file mode 100644 index 0000000..588262f --- /dev/null +++ b/packages/scala/3.2.2/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Scala requires JAVA_HOME to be set +export JAVA_HOME=$PWD +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/scala/3.2.2/metadata.json b/packages/scala/3.2.2/metadata.json new file mode 100644 index 0000000..545c824 --- /dev/null +++ b/packages/scala/3.2.2/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "scala", + "version": "3.2.2", + "aliases": ["sc"] +} \ No newline at end of file diff --git a/packages/scala/3.2.2/run b/packages/scala/3.2.2/run new file mode 100644 index 0000000..accfd16 --- /dev/null +++ b/packages/scala/3.2.2/run @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Run jar file +shift +java -jar out.jar "$@" \ No newline at end of file diff --git a/packages/scala/3.2.2/test.scala b/packages/scala/3.2.2/test.scala new file mode 100644 index 0000000..bf4cabc --- /dev/null +++ b/packages/scala/3.2.2/test.scala @@ -0,0 +1,3 @@ +@main def run(): Unit = { + println("OK") +} \ No newline at end of file diff --git a/packages/typescript/5.0.3/build.sh b/packages/typescript/5.0.3/build.sh new file mode 100644 index 0000000..c753c69 --- /dev/null +++ b/packages/typescript/5.0.3/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source ../../node/18.15.0/build.sh + +source ./environment + +bin/npm install -g typescript@5.0.3 \ No newline at end of file diff --git a/packages/typescript/5.0.3/compile b/packages/typescript/5.0.3/compile new file mode 100644 index 0000000..d674bb0 --- /dev/null +++ b/packages/typescript/5.0.3/compile @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Put instructions to compile source code, remove this file if the language does not require this stage + +rename 's/$/\.ts/' "$@" # Add .ts extension + +tsc *.ts \ No newline at end of file diff --git a/packages/typescript/5.0.3/environment b/packages/typescript/5.0.3/environment new file mode 100644 index 0000000..c6ab089 --- /dev/null +++ b/packages/typescript/5.0.3/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/typescript/5.0.3/metadata.json b/packages/typescript/5.0.3/metadata.json new file mode 100644 index 0000000..0a57acf --- /dev/null +++ b/packages/typescript/5.0.3/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "typescript", + "version": "5.0.3", + "aliases": ["ts", "node-ts", "tsc", "typescript5", "ts5"] +} \ No newline at end of file diff --git a/packages/typescript/5.0.3/run b/packages/typescript/5.0.3/run new file mode 100644 index 0000000..4ce91c5 --- /dev/null +++ b/packages/typescript/5.0.3/run @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Put instructions to run the runtime + +CODE=$1.js +shift + +node $CODE "$@" \ No newline at end of file diff --git a/packages/typescript/5.0.3/test.ts b/packages/typescript/5.0.3/test.ts new file mode 100644 index 0000000..c963843 --- /dev/null +++ b/packages/typescript/5.0.3/test.ts @@ -0,0 +1 @@ +console.log('OK'); \ No newline at end of file diff --git a/packages/vlang/0.3.3/build.sh b/packages/vlang/0.3.3/build.sh new file mode 100644 index 0000000..127bac9 --- /dev/null +++ b/packages/vlang/0.3.3/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Cloning vlang source +git clone https://github.com/vlang/v +cd v + +# Building and installing vlang +make \ No newline at end of file diff --git a/packages/vlang/0.3.3/environment b/packages/vlang/0.3.3/environment new file mode 100644 index 0000000..638b0c2 --- /dev/null +++ b/packages/vlang/0.3.3/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH="$PWD/v:$PATH" \ No newline at end of file diff --git a/packages/vlang/0.3.3/metadata.json b/packages/vlang/0.3.3/metadata.json new file mode 100644 index 0000000..4cdd7fd --- /dev/null +++ b/packages/vlang/0.3.3/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "vlang", + "version": "0.3.3", + "aliases": ["v"] +} \ No newline at end of file diff --git a/packages/vlang/0.3.3/run b/packages/vlang/0.3.3/run new file mode 100644 index 0000000..f608902 --- /dev/null +++ b/packages/vlang/0.3.3/run @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Export environment variables +export VMODULES="$PWD" +export TMPDIR="$PWD" + +# Put instructions to run the runtime + +filename=$1 + +rename 's/$/\.v/' $filename # Add .v extension + +shift +v run $filename.v "$@" \ No newline at end of file diff --git a/packages/vlang/0.3.3/test.v b/packages/vlang/0.3.3/test.v new file mode 100644 index 0000000..fb5de5e --- /dev/null +++ b/packages/vlang/0.3.3/test.v @@ -0,0 +1,3 @@ +fn main() { + println('OK') +} \ No newline at end of file diff --git a/packages/zig/0.10.1/build.sh b/packages/zig/0.10.1/build.sh new file mode 100644 index 0000000..d653709 --- /dev/null +++ b/packages/zig/0.10.1/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +mkdir -p bin +cd bin/ + +curl -L "https://ziglang.org/download/0.10.1/zig-linux-x86_64-0.10.1.tar.xz" -o zig.tar.xz +tar xf zig.tar.xz --strip-components=1 +rm zig.tar.xz + +cd ../ \ No newline at end of file diff --git a/packages/zig/0.10.1/compile b/packages/zig/0.10.1/compile new file mode 100644 index 0000000..75ee6ba --- /dev/null +++ b/packages/zig/0.10.1/compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# optimizing for small programs +rename 's/$/\.zig/' "$@" # Add .zig extension + +zig build-exe -O ReleaseSafe --color off --cache-dir . --global-cache-dir . --name out *.zig diff --git a/packages/zig/0.10.1/environment b/packages/zig/0.10.1/environment new file mode 100644 index 0000000..a85000c --- /dev/null +++ b/packages/zig/0.10.1/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# compiler path +export PATH=$PWD/bin:$PATH diff --git a/packages/zig/0.10.1/metadata.json b/packages/zig/0.10.1/metadata.json new file mode 100644 index 0000000..c7bed08 --- /dev/null +++ b/packages/zig/0.10.1/metadata.json @@ -0,0 +1,9 @@ +{ + "language": "zig", + "version": "0.10.1", + "aliases": [], + "limit_overrides": { + "compile_timeout": 15000, + "compile_cpu_time": 15000 + } +} diff --git a/packages/zig/0.10.1/run b/packages/zig/0.10.1/run new file mode 100644 index 0000000..d96e06f --- /dev/null +++ b/packages/zig/0.10.1/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +shift # Filename is only used in compile step, so we can take it out here +./out "$@" diff --git a/packages/zig/0.10.1/test.zig b/packages/zig/0.10.1/test.zig new file mode 100644 index 0000000..7cb5eb6 --- /dev/null +++ b/packages/zig/0.10.1/test.zig @@ -0,0 +1,6 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + try stdout.print("OK\n", .{}); +} diff --git a/packages/zig/0.8.0/metadata.json b/packages/zig/0.8.0/metadata.json index 8c02d33..38bc1fc 100644 --- a/packages/zig/0.8.0/metadata.json +++ b/packages/zig/0.8.0/metadata.json @@ -3,6 +3,7 @@ "version": "0.8.0", "aliases": ["zig"], "limit_overrides": { - "compile_timeout": 15000 + "compile_timeout": 15000, + "compile_cpu_time": 15000 } } diff --git a/packages/zig/0.9.1/metadata.json b/packages/zig/0.9.1/metadata.json index e7061cd..1ad7a70 100644 --- a/packages/zig/0.9.1/metadata.json +++ b/packages/zig/0.9.1/metadata.json @@ -3,6 +3,7 @@ "version": "0.9.1", "aliases": ["zig"], "limit_overrides": { - "compile_timeout": 15000 + "compile_timeout": 15000, + "compile_cpu_time": 15000 } } diff --git a/piston b/piston index fd83727..b67f44d 100755 --- a/piston +++ b/piston @@ -78,7 +78,7 @@ case $1 in clean-pkgs) git clean -fqXd packages ;; clean-repo) git clean -fqXd repo ;; - list-pkgs) find packages -depth 2 | awk -F/ '$2 && $3{ print $2 "-" $3 }' | column ;; + list-pkgs) find packages -maxdepth 2 | awk -F/ '$2 && $3{ print $2 "-" $3 }' | column ;; build-pkg) PKGSLUG="$2-$3" diff --git a/readme.md b/readme.md index 1135e90..02a712f 100644 --- a/readme.md +++ b/readme.md @@ -89,11 +89,10 @@ GET https://emkc.org/api/v2/piston/runtimes POST https://emkc.org/api/v2/piston/execute ``` -> Important Note: The Piston API is rate limited to 5 requests per second. If you have a need for more requests than that -> and it's for a good cause, please reach out to me (EngineerMan#0001) on [Discord](https://discord.gg/engineerman) -> so we can discuss potentially getting you an unlimited key. What is and isn't a good cause is up to me, but, in general -> if your project is a) open source, b) helping people at no cost to them, and c) not likely to use tons of resources -> thereby impairing another's ability to enjoy Piston, you'll likely be granted a key. +> Important Note: The Piston API is rate limited to 5 requests per second. Effective May 7, 2024, no additional +> unlimited keys will be granted and existing keys will be revoked on Jan 1, 2025. The public instance is at +> capacity and the public limit is already very generous. For usage beyond 5 requests/second, you should +> consider self hosting.
@@ -105,7 +104,8 @@ POST https://emkc.org/api/v2/piston/execute - Docker - Docker Compose -- Node JS (>= 13, preferably >= 15) +- Node JS (>= 15) +- cgroup v2 enabled, and cgroup v1 disabled ### After system dependencies are installed, clone this repository: @@ -114,6 +114,10 @@ POST https://emkc.org/api/v2/piston/execute git clone https://github.com/engineer-man/piston ``` +> [!NOTE] +> +> Ensure the repository is cloned with LF line endings + ### Installation ```sh @@ -136,8 +140,8 @@ The API will now be online with no language runtimes installed. To install runti ```sh docker run \ + --privileged \ -v $PWD:'/piston' \ - --tmpfs /piston/jobs \ -dit \ -p 2000:2000 \ --name piston_api \ @@ -246,8 +250,10 @@ This endpoint requests execution of some arbitrary code. - `files[].encoding` (_optional_) The encoding scheme used for the file content. One of `base64`, `hex` or `utf8`. Defaults to `utf8`. - `stdin` (_optional_) The text to pass as stdin to the program. Must be a string or left out. Defaults to blank string. - `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). +- `compile_timeout` (_optional_) The maximum wall-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 wall-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). +- `compile_cpu_time` (_optional_) The maximum CPU-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_cpu_time` (_optional_) The maximum CPU-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). - `compile_memory_limit` (_optional_) The maximum amount of memory the compile stage is allowed to use in bytes. Must be a number or left out. Defaults to `-1` (no limit) - `run_memory_limit` (_optional_) The maximum amount of memory the run stage is allowed to use in bytes. Must be a number or left out. Defaults to `-1` (no limit) @@ -265,6 +271,8 @@ This endpoint requests execution of some arbitrary code. "args": ["1", "2", "3"], "compile_timeout": 10000, "run_timeout": 3000, + "compile_cpu_time": 10000, + "run_cpu_time": 3000, "compile_memory_limit": -1, "run_memory_limit": -1 } @@ -274,7 +282,14 @@ A typical response upon successful execution will contain 1 or 2 keys `run` and `compile` will only be present if the language requested requires a compile stage. Each of these keys has an identical structure, containing both a `stdout` and `stderr` key, which is a string containing the text outputted during the stage into each buffer. -It also contains the `code` and `signal` which was returned from each process. +It also contains the `code` and `signal` which was returned from each process. It also includes a nullable human-readable `message` which is a description of why a stage has failed and a two-letter `status` that is either: + +- `RE` for runtime error +- `SG` for dying on a signal +- `TO` for timeout (either via `timeout` or `cpu_time`) +- `OL` for stdout length exceeded +- `EL` for stderr length exceeded +- `XX` for internal error ```json HTTP/1.1 200 OK @@ -288,7 +303,12 @@ Content-Type: application/json "stderr": "", "output": "[\n '/piston/packages/node/15.10.0/bin/node',\n '/piston/jobs/9501b09d-0105-496b-b61a-e5148cf66384/my_cool_code.js',\n '1',\n '2',\n '3'\n]\n", "code": 0, - "signal": null + "signal": null, + "message": null, + "status": null, + "cpu_time": 8, + "wall_time": 154, + "memory": 1160000 } } ``` @@ -304,6 +324,40 @@ Content-Type: application/json } ``` +#### Interactive execution endpoint (not available through the public API) + +To interact with running processes in real time, you can establish a WebSocket connection at `/api/v2/connect`. This allows you to both receive output and send input to active processes. + +Each message is structured as a JSON object with a `type` key, which indicates the action to perform. Below is a list of message types, their directions, and descriptions: + +- **init** (client -> server): Initializes a job with the same parameters as the `/execute` endpoint, except that stdin is discarded. +- **runtime** (server -> client): Provides details on the runtime environment, including the version and language. +- **stage** (server -> client): Indicates the current execution stage, either "compile" or "run." +- **data** (server <-> client): Exchanges data between the client and server, such as stdin, stdout, or stderr streams. +- **signal** (client -> server): Sends a signal (e.g., for termination) to the running process, whether it's in the "compile" or "run" stage. +- **exit** (server -> client): Signals the end of a stage, along with the exit code or signal. +- **error** (server -> client): Reports an error, typically right before the WebSocket is closed. + +An example of this endpoint in use is depicted below (**<** = client to server, **>** = server to client) + +1. Client establishes WebSocket connection to `/api/v2/connect` +2. **<** `{"type":"init", "language":"bash", "version":"*", "files":[{"content": "cat"}]}` +3. **>** `{"type":"runtime","language": "bash", "version": "5.1.0"}` +4. **>** `{"type":"stage", "stage":"run"}` +5. **<** `{"type":"data", "stream":"stdin", "data":"Hello World!"}` +6. **>** `{"type":"data", "stream":"stdout", "data":"Hello World!"}` +7. _time passes_ +8. **>** `{"type":"exit", "stage":"run", "code":null, "signal": "SIGKILL"}` + +Errors may return status codes as follows: + +- **4000: Already Initialized**: Sent when a second `init` command is issued. +- **4001: Initialization Timeout**: No `init` command was sent within 1 second of connection. +- **4002: Notified Error**: A fatal error occurred, and an `error` packet was transmitted. +- **4003: Not yet Initialized**: A non-`init` command was sent without a job context. +- **4004: Can only write to stdin**: The client attempted to write to a stream other than stdin. +- **4005: Invalid Signal**: An invalid signal was sent in a `signal` packet. +
# Supported Languages @@ -350,6 +404,7 @@ Content-Type: application/json `javascript`, `jelly`, `julia`, +`k`, `kotlin`, `lisp`, `llvm_ir`, @@ -380,6 +435,7 @@ Content-Type: application/json `rscript`, `ruby`, `rust`, +`samarium`, `scala`, `smalltalk`, `sqlite3`, @@ -396,26 +452,26 @@ Content-Type: application/json # Principle of Operation -Piston uses Docker as the primary mechanism for sandboxing. There is an API within the container written in Node -which takes in execution requests and executees them within the container safely. -High level, the API writes any source code to a temporary directory in `/piston/jobs`. +Piston uses [Isolate](https://www.ucw.cz/moe/isolate.1.html) inside Docker as the primary mechanism for sandboxing. There is an API within the container written in Node +which takes in execution requests and executes them within the container safely. +High level, the API writes any source code and executes it inside an Isolate sandbox. The source file is either ran or compiled and ran (in the case of languages like c, c++, c#, go, etc.).
# Security -Docker provides a great deal of security out of the box in that it's separate from the system. -Piston takes additional steps to make it resistant to -various privilege escalation, denial-of-service, and resource saturation threats. These steps include: +Piston uses Isolate which makes use of Linux namespaces, chroot, multiple unprivileged users, and cgroup for sandboxing and resource limiting. Code execution submissions on Piston shall not be aware of each other, shall not affect each other and shall not affect the underlying host system. This is ensured through multiple steps including: -- Disabling outgoing network interaction +- Disabling outgoing network interaction by default - Capping max processes at 256 by default (resists `:(){ :|: &}:;`, `while True: os.fork()`, etc.) - Capping max files at 2048 (resists various file based attacks) - Cleaning up all temp space after each execution (resists out of drive space attacks) -- Running as a variety of unprivileged users -- Capping runtime execution at 3 seconds -- Capping stdout to 65536 characters (resists yes/no bombs and runaway output) +- Running each submission as a different unprivileged user +- Running each submission with its own isolated Linux namespaces +- Capping runtime execution at 3 seconds by default (CPU-time and wall-time) +- Capping the peak memory that all the submission's processes can use +- Capping stdout to 1024 characters by default (resists yes/no bombs and runaway output) - SIGKILLing misbehaving code
diff --git a/repo/Dockerfile b/repo/Dockerfile index fe61a6f..86be49a 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y unzip autoconf build-essential libssl-d rm -rf /var/lib/apt/lists/* && \ update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2 -ADD entrypoint.sh mkindex.sh / +ADD entrypoint.sh mkindex.sh serve.py / ENTRYPOINT ["bash","/entrypoint.sh"] CMD ["--no-build"] diff --git a/repo/entrypoint.sh b/repo/entrypoint.sh index 6c47e37..c167463 100755 --- a/repo/entrypoint.sh +++ b/repo/entrypoint.sh @@ -27,7 +27,7 @@ do echo "Done with package $pkg" elif [[ $CI -eq 1 ]]; then echo "Commit SHA: $pkg" - + cd .. echo "Changed files:" git diff --name-only $pkg^1 $pkg @@ -52,8 +52,9 @@ echo "Index created" if [[ $SERVER -eq 1 ]]; then echo "Starting index server.." - python3 -m http.server + # We want the child process to replace the shell to handle signals + exec python3 /serve.py else echo "Skipping starting index server" fi -exit 0 \ No newline at end of file +exit 0 diff --git a/repo/serve.py b/repo/serve.py new file mode 100644 index 0000000..a821219 --- /dev/null +++ b/repo/serve.py @@ -0,0 +1,18 @@ +import signal +import sys +import http.server +import socketserver + +PORT = 8000 + +Handler = http.server.SimpleHTTPRequestHandler + + +def signal_handler(sig, frame): + sys.exit(0) + +signal.signal(signal.SIGTERM, signal_handler) + +with socketserver.TCPServer(("", PORT), Handler) as httpd: + print("serving at port", PORT) + httpd.serve_forever()