Vivarium is an implementation of Python, written in Python. It is designed to restrict the environment of executed code.
git clone https://github.com/DXsmiley/vivarium.git
The vivarium shell is very similar to the default Python one, but with fewer features.
python -m vivarium
import vivarium
untrusted_code = input('Enter the code: ')
output = vivarium.easy.run(untrusted_code)
print(output)
The vivarium.easy
module contains some helper functions to effortlessly execute code.
The vivarium.easy.run
function takes the code as a string, and returns the (print
ed) output as a list of strings.