0

I am the TA for a coding class in which students will have to write Python 3 scripts to solve programming problems. An assignment consists of several problems, and for each problem the student is supposed to write a python program that will read input from standard input and write the output to the standard output. And for each problem there will be hidden test cases that we will use to evaluate their codes and grade them accordingly. So the idea is to automatize this process as much as possible. The problem is how to implement the whole framework to run students' assignments without compromising the safety of the system the assignments will be running on, which will probably be my laptop (which has Windows 10). I need to set up some kind of sandbox for Python 3, establishing limits for execution time, memory usage, disallowing access to the file system, networking, limiting imports only to safe modules from Python's standard library, etc.

Conceptually speaking I would like some kind of sand-boxed service that can receive a python script + some tests cases, the service runs the python script against the test cases in a safe environment (detecting compilation errors, time limit exceeded errors, memory limit exceeded errors, attempts to use forbidden libraries, etc.) and reporting the results back. So from Windows I can simply write a simple script that iterates over all students submissions and uses this service as a black-box to evaluate them.

Is anything like that possible on Windows 10? If so, how? My educated guess is that something like Docker or a Virtual Machine might be useful, but to be honest I'm not really sure because I lack enough expertise in these technologies, so I'm open to any suggestions.

Any advises on how to set up a secure system for automatic evaluation of untrusted Python 3 code submissions will be very appreciated.

  • I think you already know to use virtual machine.Set it up accordingly – Vipul Nair Sep 2 at 4:01
  • It's unclear what you are asking. Are you asking for a tutorial on how to set this up? Are you asking for a product/tool to install? You ask if "it is possible" but it seems clear that you already know it is possible but you do not know how. Can you clarify? It is also not clear how this is a security problem. You want to keep your laptop safe, but your question is not about security. – schroeder Sep 2 at 9:13
  • @schroeder I edited the last two paragraphs, hopefully the question is clearer now – Pablo Messina Sep 7 at 17:09
1

pysandbox is an implementation of a sandbox in Python. It is designed to execute untrusted Python code (in our case, code submitted by a user) within a constrained environment which can be configured by a pysandbox deployer.

Please refer to this link for more information: https://www.software.ac.uk/blog/2017-11-23-executing-python-code-submitted-web-service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.