Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/w2wizard/robopeer

Send code. Wait a bit. Get response!
https://github.com/w2wizard/robopeer

bun code codegrader docker education grade grader peer peer-to-peer remote-code-execution robo untrusted-code untrusted-environments webserver

Last synced: about 4 hours ago
JSON representation

Send code. Wait a bit. Get response!

Awesome Lists containing this project

README

        


🤖 RoboPeer 🤖


Written by W2Wizard


RoboPeer is a **webserver** designed to grade your code in a safe environment. It allows you to submit code and have it "graded" without any worries about potential malicious activities.

This project was created using `bun init` in bun v1.1.4. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

## 🎯 How it Works

The grading process involves comparing the output of the provided git repository (after compiling it) to a series of tests run with `bun:test`. RoboPeer then returns the results of these tests. With an appropriate status code.

RoboPeer can also grade direct code submissions via `/evaluate/git`.

- `200` - All tests passed.
- `408` - Timeout for testing.
- `422` - Skill issue (bad code)
- `500` - RoboPeer failed.

## 🛠️ Installation
Requires [Bun.sh](https://bun.sh) to install dependencies.

To install dependencies:
```bash
bun install
```

To run:
```bash
bun run api-get # Fetches Dockers OpenAPI spec
bun run dev
```

To build:
```bash
bun run build # Outputs JS
bun run compile # Outputs a 98~mb binary
```

## 🚀 Usage

### Creating a Grading Project

To create a new reference project, use the following command:
```bash
bun run new < project-name >
```

### 🐳 Docker Setup

Make sure `Docker` is installed and running on your machine.
Build the Docker image:

```bash
#Git Image runner
docker build -t w2wizard/git ./docker/git
```

```bash
#Single Code runner
docker build -t w2wizard/single ./docker/single
```

### 📨 Sending a Grading Request
The server by default run on http://localhost:8080. To send a request to it you can use the following curl command:
```bash
# For git repositories
curl -XPOST -H "Content-type: application/json" -d '{
"data": {
"repo": "https://github.com/fbescodam/libft.git",
"branch": "master",
"commit": "67dc80a"
}
}' 'http://localhost:3001/evaluate/git/lib'
```

```bash
# For single files
# Note: This example will not work as the code is invalid
# Fork bombs won't work on the server
curl -XPOST -H "Content-type: application/json" -d '{
"data": {
"args": [],
"content": "int main() { while(1) { fork() } }",
"flags": [
"-Wno-implicit-function-declaration"
],
"lang": "c"
}
}' 'http://localhost:3001/evaluate/code'
```