Giter VIP home page Giter VIP logo

piston's Issues

Update C++ Standard to C++20

Since the C++20 standard has been published in December 2020 piston should use it.

This could be as easy as changing -std=c++17 to -std++20 in

timeout -s KILL 10 g++ -std=c++17 -o binary -x c++ code.code

but I'm not sure if the installed g++ compiler supports C++20

scala executor

See packages/ for existing examples
Please merge to v3 branch!

ruby executor

See packages/ for existing examples
Please merge to v3 branch!

[Request] Add support for POSIX shell/dash

Since dash (an implementation of POSIX sh) is already installed, it would be nice to be able to directly use it (instead of having to write to a file then execute dash with it).

Minor nit- Platforms

https://github.com/engineer-man/piston/blob/master/var/install.txt#L19 mentions debian/arch/mac os

You have Arch ๐Ÿ˜‚ debian should be analogous to Ubuntu. Ubuntu is based from Debian. I am 99% certain the packages you install have the same names. OSx would run in a VM, which could be any of the above three (that is how docker on osx works).

Suggestion

Remove at least arch. Maybe debian. Maybe make a docker image using alpine so Mac users can do something almost as easy as brew install (docker run ...)

osabie executor

See packages/ for existing examples
Please merge to v3 branch!

Different Field for Std Err

For example:

{
	"input": "there",
	"source": "print('hello' + 1)",
	"language": "python"
}

should probably respond with

{
  "ran": true,
  "language": "python",
  "version": "3.6.9",
  "output": "",
  "error": "Traceback (most recent call last):\n  File \"code.code\", line 1, in <module>\n    print('hello' + 1)\nTypeError: can only concatenate str (not \"int\") to str"
}

Hosted version appears vulnerable to CVE-2021-3156

Recent exploit was published on sudo: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt

The hosted version of piston on emkc.org though I'm not sure if this is serious given your security model.

POC:

$ curl -sX POST https://emkc.org/api/v1/piston/execute -d '{"language":"bash","source":"sudoedit -s '"'"'\\'"'"' `perl -e '"'"'print \"A\" x 65536'"'"'`","stdin":"","args":[""]}' -H "Content-Type: application/json" | jq
{
  "ran": true,
  "language": "bash",
  "version": "4.4.20",
  "output": "code.code: line 1:  2264 Segmentation fault      sudoedit -s '\\' `perl -e 'print \"A\" x 65536'`",
  "stdout": "",
  "stderr": "code.code: line 1:  2264 Segmentation fault      sudoedit -s '\\' `perl -e 'print \"A\" x 65536'`"
}

crystal executor

See packages/ for existing examples

Please merge to v3 branch!

node executor

See packages/ for existing examples
Please merge to v3 branch!

zig executor

See packages/ for existing examples

Please merge to v3 branch!

AWK executor

See packages/ for existing examples

Please merge to v3 branch!

prolog executor

See packages/ for existing examples
Please merge to v3 branch!

python3 executor

See packages/ for existing examples
Please merge to v3 branch!

Ability to install PIP packages for Python code execution

Most of the time users want a sandbox environment to test how a function from a package works; it would be very useful to have an option to provide a list of packages that should be installed on the container before code execution.

Something like this would be my suggestion to keep backward compatibility:

{
    "language": "python",
    "source": "import bcrypt\npassword = b\"super secret password\"\nhashed = bcrypt.hashpw(password, bcrypt.gensalt())\nif bcrypt.checkpw(password, hashed):\n    print('It Matches!')\nelse:\n    print('It Does not Match :(')",
    "stdin": "",
    "args": [
    ],
    "packages": [
        "bcrypt"
    ]
}

Update bash

You should update bash, the current one is ~4 years old.

perl executor

See packages/ for existing examples
Please merge to v3 branch!

cpp executor

See packages/ for existing examples

Please merge to v3 branch!

crystal executor

See packages/ for existing examples

Please merge to v3 branch!

Update rust

Update rust to a newer version, the one used currently is from 2019

Bash executor

See packages/ for existing examples

Please merge to v3 branch!

No response when running certain programs

Programs like:

bash

yes

and

cpp

#include <iostream>

int main()
{
    while (true)
    {
        &printf == 0x000;
        printf("test");
    }
}

cause the API to "hang" and not send any reply.

python2 executor

See packages/ for existing examples
Please merge to v3 branch!

rust executor

See packages/ for existing examples
Please merge to v3 branch!

php executor

See packages/ for existing examples
Please merge to v3 branch!

c executor

See packages/ for existing examples

Please merge to v3 branch!

nim executor

See packages/ for existing examples
Please merge to v3 branch!

Run Rust Test snippents.

engineer-man/piston-bot#5

I would like to implement this functionality in piston.
There are two ways I think I can do this.

  • Add rust_test as a new language which would require the least changes.
  • Add test as an arg to the rustc.
    • This might produce some changes in the current rust language behaviour.

Which path would be preferable.

swift executor

See packages/ for existing examples
Please merge to v3 branch!

paradoc executor

See packages/ for existing examples
Please merge to v3 branch!

API returns 200 on invalid language

POST to https://emkc.org/api/v1/piston/execute with a language that isn't whitelisted will result in a 200 with the response

{"output":""}

Here's some code to reproduce it:

fetch('https://emkc.org/api/v1/piston/execute', {
	method: 'POST',
	headers: {
		'Content-Type': 'application/json'
	},
	body: JSON.stringify({ language: 'randomstuff123', source: 'potatoes', args: [] }),
}).then(res => res.json()).then(console.log);

Output whitespace is trimmed

When running the below code

print(' ')

and

#include <iostream>
#include <iomanip>
std::cout << std::setw(8) << "hello" << '\n';

I would expect the outputs to be a single space for the first and

   hello

for the second but instead the bot says "Your code ran without output" on the first and outputs

hello

for the second.

Edit: the same thing happens with tabs.

Failed to fetch when installing

When i try to do the following step:

install all necessary piston dependencies

The following error comes up: (when running apt-get update)

root@piston:/# echo 'source /opt/.profile' >> /opt/.bashrc
root@piston:/# echo 'export HOME=/opt' >> /opt/.profile
root@piston:/# echo 'export TERM=linux' >> /opt/.profile
root@piston:/# echo 'export PATH=$PATH:/opt/.local/bin' >> /opt/.profile
root@piston:/# export HOME=/opt
root@piston:/# export TERM=linux
root@piston:/# sed -i 's//root//opt/' /etc/passwd
root@piston:/# sed -i \

's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' \
/etc/apt/sources.list

root@piston:/# apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:2 http://mirror.math.princeton.edu/pub/ubuntu bionic InRelease
Temporary failure resolving 'mirror.math.princeton.edu'
Err:3 http://mirror.math.princeton.edu/pub/ubuntu bionic-updates InRelease
Temporary failure resolving 'mirror.math.princeton.edu'
Reading package lists... Done
W: Failed to fetch http://mirror.math.princeton.edu/pub/ubuntu/dists/bionic/InRelease Temporary failure resolving 'mirror.math.princeton.edu'
W: Failed to fetch http://mirror.math.princeton.edu/pub/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'mirror.math.princeton.edu'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com'

Im on a debian VPS, can someone help me out?

Accept Standard Input

For example:

{
	"input": "there",
	"source": "print('hello ' + input())",
	"language": "python"
}

should respond with

{
  "ran": true,
  "language": "python",
  "version": "3.6.9",
  "output": "hello there"
}

Deno cannot import packages

Deno allows you to import from remote URLs in your code when building, however piston disables networking.
Some libraries are required (e.g. std), which you pull from a remote url

import { printf } from "https://deno.land/std/fmt/printf.ts";
printf("Hello world!")

Preserve newlines in stdin

Stdin is passed as argv, which is probably why it turns newlines into spaces. To get around this, the stdin file should be written to directly, the same way the code is.

By the way, why does the API write to a temporary file and let the executor copy it instead of just writing to the final path? Is there a reason for that? I just copied what the previous API did when rewriting it.

Piston API

Piston API is the core API which manages the lifecycle of languages and code execution.

The Piston API entails both the package manager and execution manager.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.