Skip to content

Commit e47e30e

Browse files
committed
feat!: add support for the Ulmo release
This changes also include support for openedx/codejail-service as an alternative implementation of the safe_exec REST API.
1 parent 24352f2 commit e47e30e

File tree

19 files changed

+542
-94
lines changed

19 files changed

+542
-94
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: ['3.9', '3.12']
19+
python-version: ['3.10', '3.12']
2020

2121
steps:
2222
- uses: actions/checkout@v4

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
3636

3737
quality: ## check coding style with pycodestyle and pylint
3838
pylint tutorcodejail *.py
39-
pycodestyle tutorcodejail *.py
40-
pydocstyle tutorcodejail *.py
4139
isort --check-only --diff --recursive tutorcodejail *.py
4240
python setup.py bdist_wheel
4341
twine check dist/*

README.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
Codejail plugin for `Tutor`_
22
============================
33

4-
Tutor plugin that configures and runs a `Codejail Service`_ using a REST API. `Codejail`_ allows for the
5-
secure execution of untrusted code within sandboxes, providing a safe environment for running potentially dangerous code.
4+
Tutor plugin that configures and runs a `Codejail Service`_ using a REST API.
5+
`Codejail`_ allows for the secure execution of untrusted code within sandboxes,
6+
providing a safe environment for running potentially dangerous code.
7+
8+
Starting from the Ulmo release, the codejail plugin is transitioning to an
9+
alternative implementation of the safe-exec API ( `Codejail Service V2`_).
10+
You can opt-in to use this new implementation on Ulmo before it finally becomes
11+
the default on the Verawood release.
612

713
.. _Tutor: https://docs.tutor.overhang.io
814
.. _Codejail Service: https://github.com/eduNEXT/codejailservice
15+
.. _Codejail Service V2: https://github.com/openedx/codejail-service
916
.. _Codejail: https://github.com/openedx/codejail
1017

1118
Installation
@@ -23,9 +30,9 @@ You can install a specific version by adding the tag, branch, or commit:
2330

2431
.. code-block:: bash
2532
26-
pip install tutor-contrib-codejail==v20.0.0
33+
pip install tutor-contrib-codejail~=21.0
2734
# or install from the source
28-
pip install git+https://github.com/edunext/tutor-contrib-codejail@v20.0.0
35+
pip install git+https://github.com/edunext/tutor-contrib-codejail@v21.0.0
2936
3037
Usage
3138
-----
@@ -55,14 +62,26 @@ Configuration
5562
To customize the configuration, update the following settings in Tutor:
5663

5764
- ``CODEJAIL_APPARMOR_DOCKER_IMAGE``: (default: ``docker.io/ednxops/codejail_apparmor_loader:latest``)
65+
- ``CODEJAIL_DOCKER_IMAGE_V2`` : (default: ``{{ CODEJAIL_DOCKER_IMAGE }}-v2``)
5866
- ``CODEJAIL_DOCKER_IMAGE``: (default: ``docker.io/ednxops/codejailservice:{{__version__}}``)
5967
- ``CODEJAIL_ENABLE_K8S_DAEMONSET`` (default: ``False``)
6068
- ``CODEJAIL_ENFORCE_APPARMOR`` (default: ``True``)
6169
- ``CODEJAIL_EXTRA_PIP_REQUIREMENTS`` (default: ``[]``)
6270
- ``CODEJAIL_SANDBOX_PYTHON_VERSION`` (default: ``3.11.9``)
63-
- ``CODEJAIL_SERVICE_REPOSITORY`` (default ``https://github.com/edunext/codejailservice.git```)
64-
- ``CODEJAIL_SERVICE_VERSION`` (default: ``release/teak.1``),
71+
- ``CODEJAIL_SERVICE_REPOSITORY`` (default: ``https://github.com/edunext/codejailservice.git```)
72+
- ``CODEJAIL_SERVICE_VERSION`` (default: ``{{ OPENEDX_COMMON_VERSION }}``),
6573
- ``CODEJAIL_SKIP_INIT`` (default: ``False``)
74+
- ``SERVICE_V2_REPOSITORY``: (default: ``https://github.com/openedx/codejail-service.git``)
75+
- ``SERVICE_V2_VERSION``: (default: ``{{ OPENEDX_COMMON_VERSION }}``)
76+
- ``USE_SERVICE_V2``: (default: ``False``)
77+
78+
The ``CODEJAIL_V2_*`` settings are meant to be used only during the Ulmo
79+
release and will be phased-out during the Verawood release.
80+
81+
To opt-in to the new implementation of the code-exec API set ``USE_SERVICE_V2``
82+
to ``True`` and re-deploy your environment. If you are using a a custom image
83+
for the codejail service you will need to rebuild it with ``USE_SERVICE_V2``
84+
set to ``True``.
6685

6786
Custom Image
6887
~~~~~~~~~~~~
@@ -109,6 +128,8 @@ Compatibility
109128
+------------------+---------------+
110129
| Teak | >= 20.x |
111130
+------------------+---------------+
131+
| Ulmo | >= 21.x |
132+
+------------------+---------------+
112133

113134
**NOTE**: For the Open edX version of the Lilac release, the changes required for the Codejail service to interact with ``edx-platform`` are
114135
not included in ``open-release/lilac.master``. To use the service with the changes, please review `this PR`_.

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[MASTER]
2-
ignore = migrations
2+
ignore = migrations,patches,templates
33
persistent = yes
44

55
[MESSAGES CONTROL]

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,15 @@ def load_about():
4343
long_description=load_readme(),
4444
packages=find_packages(exclude=["tests*"]),
4545
include_package_data=True,
46-
python_requires=">=3.8",
47-
install_requires=["tutor>=20.0.0,<21"],
46+
python_requires=">=3.10",
47+
install_requires=["tutor~=21.0"],
4848
entry_points={"tutor.plugin.v1": ["codejail = tutorcodejail.plugin"]},
4949
classifiers=[
5050
"Development Status :: 3 - Alpha",
5151
"Intended Audience :: Developers",
5252
"License :: OSI Approved :: GNU Affero General Public License v3",
5353
"Operating System :: OS Independent",
5454
"Programming Language :: Python",
55-
"Programming Language :: Python :: 3.8",
56-
"Programming Language :: Python :: 3.9",
5755
"Programming Language :: Python :: 3.10",
5856
"Programming Language :: Python :: 3.11",
5957
"Programming Language :: Python :: 3.12",

tutorcodejail/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Helps you keep your cool when creating dozens of open edX and eduNEXT environments."""
2-
__version__ = "20.1.0"
2+
__version__ = "21.0.0"

tutorcodejail/patches/k8s-deployments

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
{% if CODEJAIL_USE_SERVICE_V2 %}
23
apiVersion: apps/v1
34
kind: Deployment
45
metadata:
@@ -13,11 +14,49 @@ spec:
1314
metadata:
1415
labels:
1516
app.kubernetes.io/name: codejailservice
16-
annotations:
17-
{% if CODEJAIL_ENFORCE_APPARMOR %}
18-
container.apparmor.security.beta.kubernetes.io/codejailservice: "localhost/docker-edx-sandbox"
19-
{% endif %}
2017
spec:
18+
securityContext:
19+
appArmorProfile:
20+
type: Localhost
21+
localhostProfile: openedx_codejail_service
22+
containers:
23+
- name: codejailservice
24+
image: {{ CODEJAIL_DOCKER_IMAGE_V2 }}
25+
ports:
26+
- containerPort: 8550
27+
env:
28+
- name: DJANGO_SETTINGS_MODULE
29+
value: codejail_service.settings.tutor
30+
volumeMounts:
31+
- mountPath: /app/codejail_service/settings/tutor.py
32+
name: settings-codejail
33+
subPath: tutor.py
34+
volumes:
35+
- name: settings-codejail
36+
configMap:
37+
name: settings-codejail
38+
{% else %}
39+
apiVersion: apps/v1
40+
kind: Deployment
41+
metadata:
42+
name: codejailservice
43+
labels:
44+
app.kubernetes.io/name: codejailservice
45+
spec:
46+
selector:
47+
matchLabels:
48+
app.kubernetes.io/name: codejailservice
49+
template:
50+
metadata:
51+
labels:
52+
app.kubernetes.io/name: codejailservice
53+
spec:
54+
{% if CODEJAIL_ENFORCE_APPARMOR %}
55+
securityContext:
56+
appArmorProfile:
57+
type: Localhost
58+
localhostProfile: docker-edx-sandbox
59+
{% endif %}
2160
containers:
2261
- name: codejailservice
2362
image: {{ CODEJAIL_DOCKER_IMAGE }}
@@ -34,6 +73,7 @@ spec:
3473
- name: settings-codejail
3574
configMap:
3675
name: settings-codejail
76+
{% endif %}
3777
{% if CODEJAIL_ENABLE_K8S_DAEMONSET %}
3878
---
3979
apiVersion: apps/v1

tutorcodejail/patches/k8s-services

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ apiVersion: v1
33
kind: Service
44
metadata:
55
name: codejailservice
6+
labels:
7+
app.kubernetes.io/name: codejailservice
68
spec:
79
type: ClusterIP
810
ports:
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
- name: codejail-profile
22
files:
3-
- plugins/codejail/apps/profiles/docker-edx-sandbox
3+
- plugins/codejail/apps/profiles/docker-edx-sandbox.profile
4+
- plugins/codejail/apps/profiles/openedx-codejail-service.profile
45
options:
56
labels:
67
app.kubernetes.io/name: codejail-aa-loader
78
- name: settings-codejail
89
files:
9-
- plugins/codejail/apps/config/tutor.py
10+
{% if CODEJAIL_USE_SERVICE_V2 %}
11+
- plugins/codejail/apps/codejail-service-v2/tutor.py
12+
{% else %}
13+
- plugins/codejail/apps/codejail/tutor.py
14+
{% endif %}
1015
options:
1116
labels:
1217
app.kubernetes.io/name: codejailservice
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
codejail-apparmor-job:
2+
image: {{ CODEJAIL_APPARMOR_DOCKER_IMAGE }}
3+
privileged: true
4+
environment:
5+
SKIP_INIT: "{{ CODEJAIL_SKIP_INIT }}"
6+
volumes:
7+
- ../plugins/codejail/apps/profiles/:/profiles/:ro
8+
- /sys:/sys
9+
- /etc/apparmor.d:/etc/apparmor.d

0 commit comments

Comments
 (0)