Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1computer1/myriad
Arbitrary code execution
https://github.com/1computer1/myriad
code docker eval haskell servant
Last synced: about 2 months ago
JSON representation
Arbitrary code execution
- Host: GitHub
- URL: https://github.com/1computer1/myriad
- Owner: 1Computer1
- License: mit
- Created: 2019-07-09T09:18:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-31T04:20:21.000Z (over 3 years ago)
- Last Synced: 2023-03-05T06:59:28.646Z (almost 2 years ago)
- Topics: code, docker, eval, haskell, servant
- Language: Haskell
- Size: 99.6 KB
- Stars: 23
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Myriad
Arbitrary code execution server using Docker.
Each language has its own Docker image and so each evaluation will run in the respective language's locked-down container.Features include:
- Building images on startup.
- Preparing containers on startup or on demand.
- Periodically cleanup running containers.
- Customizable settings for each image:
- Maximum memory usage.
- Maximum CPU usage.
- Maximum evaluation time.
- Maximum concurrent evaluations.
- Maximum number of retries.
- Maximum output size.Requires Docker 18+ to operate.
## Download Pre-Built Binary
Check the `Releases` tab for pre-built binaries.
The languages folder and an example configuration are also included.## Installation from Source
You can use either `stack` or `cabal`.
- `stack` should be >= 2.1.1, `cabal` should be >= 2.4.0.0.
- GHC 8.8.3 is required if not already installed by `stack` or if using `cabal`.Make sure the place where `stack` or `cabal` places binaries is in your PATH.
- For `stack`, you can get it with `stack path --local-bin`.
- For `cabal`, you should find it in `$HOME/.cabal/bin` (Linux) or `%APPDATA%\cabal\bin` (Windows).Run `stack install` or `cabal new-install` inside the project folder.
Or, to build within the project, run `stack build` or `cabal new-build`.## Configure and Run
Make sure the configuration is filled out, see `config.example.yaml` for an example.
Run `myriad` (or `stack run` or `cabal new-run` if you built within the project) to start the server.
The config and languages folder will default to `./config.yaml` and `./languages`.
You can configure this with `--config` and `--languages`.## Endpoints
### **GET** `/languages`
List of enabled languages.
Example response:```json
["haskell", "javascript"]
```### **POST** `/eval`
Evaluate code.
JSON payload with `language` and `code` keys.
The `language` is as in the name of a subfolder in the `languages` directory.
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.
### **GET** `/containers`
List of containers being handled by Myriad.
### **POST** `/cleanup`
Kill all containers, giving back the names of the containers killed.