C++ Backend - Remote Script Execution
For some context im working on this leetcode type application im trying to write where people can post their own questions, submit solutions, leaderboards etc. The user will be presented with a question, some examples and a function prototype they need to implement for the solution. I've come pretty far along but now I just need to handle running the scripts securely, without too much overhead. Having some sort of test case generation (I'll implement the whole TLE and Space Limit stuff later)
Now what I'm thinking for the "secure" part is to have a pool of docker containers or something, I use when available.
For running the Python scripts I'm thinking of having some sort of Python wrapper that takes in the script's path imports the function and runs it against our generated test cases. Now for our test case generation, I was thinking of having like a config file type thing the user fills out to determine what kind of inputs and outputs to expect. But this all still feels like a lot of work for a person to do to post a question. (question body, correct answer script and a config defining function prototype, return types etc).
Idk, what I'm getting at is this just feels like a bit of a shitty way to approach this problem and was looking for alternate POVs to how I can implement something like this.
https://github.com/mush1e/RCE
P.S (Don't ask me why it's in C++, I'm a bit special in the head)
GitHub
GitHub - mush1e/RCE: Remote Code Execution Platform
Remote Code Execution Platform. Contribute to mush1e/RCE development by creating an account on GitHub.
27 Replies
pls elp my brain hurts ;-;
Unfortunately low overhead and docker do not mix
I was thinking alternately to just have a process and restrict its resources
Are you trying to host on Linux?
Yeah
I’m sure you can figure that out then. What’s the problem?
I think ive just hit a mental roadblock rn tbh
The question is whose experience are you optimizing for, the poster or the solver
Solver
But i dont want it to be annoying for the poster either
Idk doing the whole config thing seems like alot
I essentially want this to be something that we could use for the dsa course
Config doesn’t sound too bad if it’s well documented. If it’s JSON it will be easy to fill out
I could also just have a form that ill turn to json
Tbh forms are cancer. Your poster are gonna be programmers, they will probably prefer to work with json in their favorite text editor than a web form
Yeah youre right
Forms are so cancer
Keep it simple
If anything doing this project has been teaching me a shitload
Start with something standard and quick to implement - JSON
Yeah im pretty sure ive also written a json parser for my backend so works out
Or just use an existing one if you’re lazy like me
Lmao true
I doubt the perf of parsing will matter because your JSON payloads should be small
Focus on getting blazingly fast submission and execution for that blessed solver UX
Yeah honestly the whole point of this project was to get from nothing to a decent web app
Which is why im trying to handroll everything
Some things just ain’t worth hand rolling
Certainly not a JSON parser
In hindsight i do agree
Like all the threadpool stuff was fun but implementing http was alot
It’s never a wasted opportunity to learn but if you want to get things out in a reasonable timeframe you gotta cave to the libs
Atleast I can write a juicy article about it when im done :3
That’s the spirit
Milk it like a cow’s tit
Damn I should write some articles