2019-07-09 11:19:41 +02:00
|
|
|
# Myriad
|
|
|
|
|
|
|
|
Arbitrary code execution server using Docker.
|
|
|
|
|
2019-07-11 07:00:41 +02:00
|
|
|
## Install
|
2019-07-09 11:19:41 +02:00
|
|
|
|
2019-09-05 05:56:37 +02:00
|
|
|
- Install GHC and Cabal, see [the Haskell website](https://www.haskell.org/)
|
|
|
|
- Run `cabal new-install`, a `myriad` executable will be installed
|
2019-07-11 07:00:41 +02:00
|
|
|
|
|
|
|
## Running
|
|
|
|
|
2019-09-05 16:17:08 +02:00
|
|
|
- Make sure the configuration is filled out, see `config.example.dhall` for an example
|
|
|
|
- Run `myriad --config /path/to/config.dhall --languages /path/to/languages/`
|
2019-07-09 11:19:41 +02:00
|
|
|
|
|
|
|
## Endpoints
|
|
|
|
|
2019-07-09 11:32:27 +02:00
|
|
|
### **GET** `/languages`
|
2019-09-05 05:53:57 +02:00
|
|
|
|
2019-07-09 11:19:41 +02:00
|
|
|
List of enabled languages.
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
["haskell", "javascript"]
|
|
|
|
```
|
|
|
|
|
2019-07-09 11:32:27 +02:00
|
|
|
### **POST** `/eval`
|
2019-09-05 05:53:57 +02:00
|
|
|
|
2019-07-09 11:19:41 +02:00
|
|
|
Evaluate code.
|
|
|
|
JSON payload with `language` and `code` keys.
|
2019-07-11 06:25:50 +02:00
|
|
|
The `language` is as in the name of a subfolder in the `languages` directory.
|
2019-07-09 11:19:41 +02:00
|
|
|
Example payload:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{ "language": "haskell", "code": "main = print (1 + 1)" }
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{ "result": "2\n" }
|
|
|
|
```
|
|
|
|
|
|
|
|
Errors with 404 if `language` is not found, `504` if evaluation timed out, or `500` if evaluation failed for other reasons.
|
2019-07-11 08:20:36 +02:00
|
|
|
|
|
|
|
### **GET** `/containers`
|
2019-09-05 05:53:57 +02:00
|
|
|
|
2019-07-11 08:20:36 +02:00
|
|
|
List of containers being handled by Myriad.
|
|
|
|
|
|
|
|
### **POST** `/cleanup`
|
2019-09-05 05:53:57 +02:00
|
|
|
|
2019-07-11 08:20:36 +02:00
|
|
|
Kill all containers, giving back the names of the containers killed.
|