Package containing various utility functions used for remote-exercise-framework submission procedure
Check requirements.txt
git clone [email protected]:remote-exercise-framework/ref-utils.git
cd ref-utils
pip install -f requirements.txt
Produce pip-installable file with
python3 setup.py bdist_wheel
drop_privilegesanddrop_privileges_to(uid, gid)decorates allow to execute function in unprivileged context- TODO: ctxt mgr?
Return Boolean value (False) instead of AssertionError in case of failure
assert_is_file- check whether given path points to fileassert_is_executable- check whether given path points to executable fileassert_is_dir- check whether given path points to directory
Colored output
print_ok- prints text greenprint_warn- prints text yellowprint_err- prints text red
Run (shell) command after dropping privileges. Wraps subprocess.run
run- subprocess.runrun_shell- subprocess.run withshell=True.
Various checks to run on instances
run_pylint- pylint linter - disable by setting environment variable NO_LINT="1"run_mypy- mypy type checker - disable by setting environment variable NO_LINT="1"contains_flag- execute given python script with python3 and check whether output contains a given flag value- TODO: stuff like:
exec_trace = exec(/submitted_file); assert_executes_syscalls(exec_trace, 'write /flag' )