sio2project / sioworkers

GNU General Public License v3.0
11 stars 22 forks source link

Integrating Python as allowed compiler #8

Open enedil opened 7 years ago

enedil commented 7 years ago

Hello. I was thinking of possibility of a work around for running Python with oioioi. Currently project requires to run a binary. This could be resolved using Cython - Python code would be transpiled to C or C++ source and then compiled with appropriate compiler. This however would impose double step in compilation with seems to break the current process as there is no support for variable number of steps which produce binary. Any guidance on whether it is even needed and if so, how to proceed?

matrach commented 7 years ago

It's actually pretty straightforward to add a basic support for Python using the mechanism created for Java solutions, which are not compiled to binaries, but to bytecode, instead. The tricky part is making it secure, especially that, the currently used supervisor is not open-sourced. In case you can disregard this, the current source->execution flow for Java is as follows:

  1. The .java file is converted to a jar in two steps implemented here for using system-provided JDK and here for a custom one.
  2. The resulting file is sent back to the frontend, and then distributed to the workers grading tests.
  3. File runners handle running non-executable files. They just create a shell command suitable to be run within a specific executor.

In the codebase you'll encounter three main concepts:

enedil commented 7 years ago

Correct me if I'm wrong, but would it be as secure as it's with C solutions if Python was translated to C and then graded and executed as any other C solution?

matrach commented 7 years ago

It depends on the translation. AFAIU Cython creates Python extensions, which still require the Python runtime to run inside the supervisor. So, from the security standpoint, it doesn't matter, if the code is compiled or interpreted by Python. The issue is that, the supervisor might be too harsh for the runtime – it allows only a very limited subset of syscalls. If the Python code would be translated to vanilla C/C++, limited only to the stdlib, it would be another story.

Wolf480pl commented 5 years ago

We switched to from the closed-source supervisor to sio2jail, and as I've said in sio2project/oioioi#9, we have a working support for Python, up and running on sio2.mimuw.edu.pl. The relevant patches are in the process of code review before inclusion in the official codebase.

A-dead-pixel commented 1 year ago

We switched to from the closed-source supervisor to sio2jail, and as I've said in sio2project/oioioi#9, we have a working support for Python, up and running on sio2.mimuw.edu.pl. The relevant patches are in the process of code review before inclusion in the official codebase.

Any progress on this?

Wolf480pl commented 1 year ago

It needs some unit tests, and nobody has time and energy to write them