tutor-contrib-codejail 18.0.0__tar.gz → 19.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {tutor_contrib_codejail-18.0.0/tutor_contrib_codejail.egg-info → tutor_contrib_codejail-19.0.0}/PKG-INFO +2 -2
  2. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/setup.py +1 -1
  3. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0/tutor_contrib_codejail.egg-info}/PKG-INFO +2 -2
  4. tutor_contrib_codejail-19.0.0/tutor_contrib_codejail.egg-info/requires.txt +1 -0
  5. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/__about__.py +1 -1
  6. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/k8s-deployments +1 -1
  7. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/local-docker-compose-services +1 -1
  8. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/plugin.py +33 -2
  9. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/apps/profiles/docker-edx-sandbox +11 -11
  10. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/build/codejail/Dockerfile +25 -21
  11. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/build/codejail_apparmor/Dockerfile +3 -4
  12. tutor_contrib_codejail-18.0.0/tutor_contrib_codejail.egg-info/requires.txt +0 -1
  13. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/LICENSE +0 -0
  14. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/MANIFEST.in +0 -0
  15. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/README.rst +0 -0
  16. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/setup.cfg +0 -0
  17. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutor_contrib_codejail.egg-info/SOURCES.txt +0 -0
  18. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutor_contrib_codejail.egg-info/dependency_links.txt +0 -0
  19. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutor_contrib_codejail.egg-info/entry_points.txt +0 -0
  20. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutor_contrib_codejail.egg-info/top_level.txt +0 -0
  21. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/__init__.py +0 -0
  22. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/.gitignore +0 -0
  23. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/cms-env +0 -0
  24. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/k8s-jobs +0 -0
  25. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/k8s-services +0 -0
  26. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/kustomization-configmapgenerator +0 -0
  27. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/kustomization-resources +0 -0
  28. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/lms-env +0 -0
  29. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/local-docker-compose-dev-services +0 -0
  30. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/patches/local-docker-compose-jobs-services +0 -0
  31. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/apps/.gitignore +0 -0
  32. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/apps/config/tutor.py +0 -0
  33. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/build/.gitignore +0 -0
  34. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/k8s/.gitignore +0 -0
  35. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/k8s/hpa.yml +0 -0
  36. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/tasks/.gitignore +0 -0
  37. {tutor_contrib_codejail-18.0.0 → tutor_contrib_codejail-19.0.0}/tutorcodejail/templates/codejail/tasks/codejail-apparmor/init +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tutor-contrib-codejail
3
- Version: 18.0.0
3
+ Version: 19.0.0
4
4
  Summary: Codejail plugin for Tutor
5
5
  Home-page: https://github.com/github/tutor-contrib-codejail
6
6
  Author: eduNEXT
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Requires-Python: >=3.8
21
21
  License-File: LICENSE
22
- Requires-Dist: tutor<19,>=18.0.0
22
+ Requires-Dist: tutor<20,>=19.0.0
23
23
 
24
24
  Codejail plugin for `Tutor`_
25
25
  ============================
@@ -44,7 +44,7 @@ setup(
44
44
  packages=find_packages(exclude=["tests*"]),
45
45
  include_package_data=True,
46
46
  python_requires=">=3.8",
47
- install_requires=["tutor>=18.0.0, <19"],
47
+ install_requires=["tutor>=19.0.0, <20"],
48
48
  entry_points={"tutor.plugin.v1": ["codejail = tutorcodejail.plugin"]},
49
49
  classifiers=[
50
50
  "Development Status :: 3 - Alpha",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tutor-contrib-codejail
3
- Version: 18.0.0
3
+ Version: 19.0.0
4
4
  Summary: Codejail plugin for Tutor
5
5
  Home-page: https://github.com/github/tutor-contrib-codejail
6
6
  Author: eduNEXT
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Requires-Python: >=3.8
21
21
  License-File: LICENSE
22
- Requires-Dist: tutor<19,>=18.0.0
22
+ Requires-Dist: tutor<20,>=19.0.0
23
23
 
24
24
  Codejail plugin for `Tutor`_
25
25
  ============================
@@ -1,2 +1,2 @@
1
1
  """Helps you keep your cool when creating dozens of open edX and eduNEXT environments."""
2
- __version__ = "18.0.0"
2
+ __version__ = "19.0.0"
@@ -15,7 +15,7 @@ spec:
15
15
  app.kubernetes.io/name: codejailservice
16
16
  annotations:
17
17
  {% if CODEJAIL_ENFORCE_APPARMOR %}
18
- container.apparmor.security.beta.kubernetes.io/codejailservice: "localhost/docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }}"
18
+ container.apparmor.security.beta.kubernetes.io/codejailservice: "localhost/docker-edx-sandbox"
19
19
  {% endif %}
20
20
  spec:
21
21
  containers:
@@ -5,7 +5,7 @@ codejailservice:
5
5
  FLASK_APP_SETTINGS: codejailservice.tutor.ProductionConfig
6
6
  {% if CODEJAIL_ENFORCE_APPARMOR %}
7
7
  security_opt:
8
- - apparmor:docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }}
8
+ - apparmor:docker-edx-sandbox
9
9
  {% endif %}
10
10
  volumes:
11
11
  - ../plugins/codejail/apps/config/tutor.py:/openedx/codejailservice/codejailservice/tutor.py:ro
@@ -3,19 +3,22 @@ from __future__ import annotations
3
3
 
4
4
  import os
5
5
  from glob import glob
6
+ from pathlib import Path
6
7
 
7
8
  import importlib_resources
8
9
  from tutor import hooks
9
10
 
10
11
  from .__about__ import __version__
11
12
 
13
+ ABI_PATH = "/etc/apparmor.d/abi"
14
+
12
15
  config = {
13
16
  "unique": {
14
17
  "SECRET_KEY": "{{ 24|random_string }}",
15
18
  },
16
19
  "defaults": {
17
20
  "VERSION": __version__,
18
- "APPARMOR_DOCKER_IMAGE": "docker.io/ednxops/codejail_apparmor_loader:latest",
21
+ "APPARMOR_DOCKER_IMAGE": "docker.io/ednxops/codejail_apparmor_loader:apparmor-3",
19
22
  "DOCKER_IMAGE": f"docker.io/ednxops/codejailservice:{__version__}",
20
23
  "ENABLE_K8S_DAEMONSET": False,
21
24
  "ENFORCE_APPARMOR": True,
@@ -30,13 +33,41 @@ config = {
30
33
  "MIN_REPLICAS": 1,
31
34
  "MAX_REPLICAS": 4,
32
35
  "AVG_CPU": 65,
33
- "SERVICE_VERSION": "release/redwood.1",
36
+ "SERVICE_VERSION": "release/sumac.1",
34
37
  "SERVICE_REPOSITORY": "https://github.com/edunext/codejailservice.git",
35
38
  },
36
39
  "overrides": {},
37
40
  }
38
41
 
39
42
 
43
+ def get_apparmor_abi():
44
+ """
45
+ Return the default abi 3.0 rule if available in the system.
46
+
47
+ AppArmor uses the Policy feature ABI to establish which rules it can
48
+ enforce based on the kernel capabilities. AppArmor profiles can include an
49
+ ABI rule to indicate the ABI they were developed under. If no rule is used
50
+ AppArmor will fallback to whichever rule is pinned in the
51
+ `/etc/apparmor/parser.conf` file.
52
+
53
+ We try to use the 3.0 abi whenever it's available at `/etc/apparmor.d/abi/`
54
+ to guarantee that network rules are correctly enforced on newer versions of
55
+ the kernel. If the ABI is not present we don't set the abi rule and instead
56
+ rely on the default fallback.
57
+
58
+ See: https://github.com/netblue30/firejail/issues/3659#issuecomment-711074899
59
+ """
60
+ if Path(f"{ABI_PATH}/3.0").exists():
61
+ return "abi <abi/3.0>,"
62
+ return ""
63
+
64
+
65
+ hooks.Filters.ENV_TEMPLATE_VARIABLES.add_items(
66
+ [
67
+ ("get_apparmor_abi", get_apparmor_abi()),
68
+ ]
69
+ )
70
+
40
71
  # To add a custom initialization task, create a bash script template under:
41
72
  # tutorcodejail/templates/codejail/tasks/
42
73
  # and then add it to the MY_INIT_TASKS list. Each task is in the format:
@@ -1,6 +1,8 @@
1
1
  #include <tunables/global>
2
2
 
3
- profile docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }} flags=(attach_disconnected,mediate_deleted) {
3
+ {{ get_apparmor_abi }}
4
+
5
+ profile docker-edx-sandbox flags=(attach_disconnected,mediate_deleted) {
4
6
  #include <abstractions/base>
5
7
 
6
8
  network,
@@ -9,7 +11,7 @@ profile docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }} flags=(attach_d
9
11
  umount,
10
12
  signal (receive) peer=unconfined,
11
13
  signal (receive) peer=cri-containerd.apparmor.d,
12
- signal (send,receive) peer=docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }},
14
+ signal (send,receive) peer=docker-edx-sandbox,
13
15
 
14
16
  deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
15
17
  # deny write to files not in /proc/<number>/** or /proc/sys/**
@@ -30,7 +32,7 @@ profile docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }} flags=(attach_d
30
32
  deny /sys/firmware/** rwklx,
31
33
  deny /sys/kernel/security/** rwklx,
32
34
 
33
- ptrace (trace,read) peer=docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }},
35
+ ptrace (trace,read) peer=docker-edx-sandbox,
34
36
 
35
37
  /sandbox/venv/bin/python Cx -> child,
36
38
  profile child flags=(attach_disconnected,mediate_deleted){
@@ -39,20 +41,18 @@ profile docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }} flags=(attach_d
39
41
  #
40
42
  # Python abstractions adapted from https://gitlab.com/apparmor/apparmor/-/raw/master/profiles/apparmor.d/abstractions/python
41
43
  #
42
- /opt/pyenv/versions/3.[0-9].*/lib/python3.[0-9]/**.{pyc,so} mr,
43
- /opt/pyenv/versions/3.[0-9].*/lib/python3.[0-9]/**.{egg,py,pth} r,
44
- /opt/pyenv/versions/3.[0-9].*/lib/python3.[0-9]/site-packages/ r,
45
- /opt/pyenv/versions/3.[0-9].*/lib/python3.[0-9]/lib-dynload/*.so mr,
46
-
47
- /opt/pyenv/versions/3.[0-9].*/include/python3.[0-9]*/pyconfig.h r,
48
-
44
+ /opt/pyenv/versions/{3.[0-9],3.[1-9][0-9]}.*/lib/python{3.[0-9],3.[1-9][0-9]}/**.{pyc,so} mr,
45
+ /opt/pyenv/versions/{3.[0-9],3.[1-9][0-9]}.*/lib/python{3.[0-9],3.[1-9][0-9]}/**.{egg,py,pth} r,
46
+ /opt/pyenv/versions/{3.[0-9],3.[1-9][0-9]}.*/lib/python{3.[0-9],3.[1-9][0-9]}/site-packages/ r,
47
+ /opt/pyenv/versions/{3.[0-9],3.[1-9][0-9]}.*/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/*.so mr,
48
+ /opt/pyenv/versions/{3.[0-9],3.[1-9][0-9]}.*/include/python{3.[0-9],3.[1-9][0-9]}*/pyconfig.h r,
49
49
 
50
50
  #
51
51
  # Whitelist particiclar shared objects from the system
52
52
  # python installation
53
53
  #
54
54
  /sandbox/venv/** mr,
55
- /opt/pyenv/versions/{{ CODEJAIL_SANDBOX_PYTHON_VERSION }}_sandbox/** mr,
55
+ /opt/pyenv/versions/{3.[0-9],3.[1-9][0-9]}.*_sandbox/** mr,
56
56
  /tmp/codejail-*/ rix,
57
57
  /tmp/codejail-*/** wrix,
58
58
  /tmp/* wrix,
@@ -1,41 +1,42 @@
1
- FROM docker.io/ubuntu:22.04 as minimal
2
- MAINTAINER edunext.co <contact@edunext.co>
1
+ FROM docker.io/ubuntu:22.04 AS minimal
2
+ LABEL mantainer="edunext.co <contact@edunext.co>"
3
3
 
4
4
  ENV DEBIAN_FRONTEND=noninteractive
5
5
  RUN apt update && \
6
6
  apt install -y build-essential curl git language-pack-en llvm
7
- ENV LC_ALL en_US.UTF-8
7
+ ENV LC_ALL=en_US.UTF-8
8
8
 
9
9
  ###### Install python with pyenv in /opt/pyenv and create virtualenv in /openedx/venv
10
- FROM minimal as python
10
+ FROM minimal AS python
11
11
  # https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites
12
12
  RUN apt update && \
13
13
  apt install -y libssl-dev zlib1g-dev libbz2-dev \
14
14
  libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
15
15
  xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git subversion
16
- ENV PYENV_ROOT /opt/pyenv
16
+ ENV PYENV_ROOT=/opt/pyenv
17
17
  RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.4.0 --depth 1
18
18
 
19
19
  ARG CODEJAILSERVICE_PYTHON_VERSION=3.11.9
20
20
  RUN $PYENV_ROOT/bin/pyenv install $CODEJAILSERVICE_PYTHON_VERSION
21
21
 
22
- ARG SANDBOX_PYTHON_VERSION={{ CODEJAIL_SANDBOX_PYTHON_VERSION }}
22
+ ARG SANDBOX_PYTHON_VERSION="{{ CODEJAIL_SANDBOX_PYTHON_VERSION }}"
23
23
  RUN git clone https://github.com/esinker/pyenv-version-alias $PYENV_ROOT/plugins/pyenv-alias
24
- RUN VERSION_ALIAS={{ CODEJAIL_SANDBOX_PYTHON_VERSION }}_sandbox $PYENV_ROOT/bin/pyenv install -f $SANDBOX_PYTHON_VERSION
24
+ RUN VERSION_ALIAS="{{ CODEJAIL_SANDBOX_PYTHON_VERSION }}_sandbox" \
25
+ $PYENV_ROOT/bin/pyenv install -f $SANDBOX_PYTHON_VERSION
25
26
 
26
- RUN $PYENV_ROOT/versions/$CODEJAILSERVICE_PYTHON_VERSION/bin/python -m venv /openedx/venv
27
- RUN $PYENV_ROOT/versions/"$SANDBOX_PYTHON_VERSION"_sandbox/bin/python -m venv --copies /sandbox/venv
27
+ RUN "$PYENV_ROOT/versions/$CODEJAILSERVICE_PYTHON_VERSION/bin/python" -m venv /openedx/venv
28
+ RUN "$PYENV_ROOT/versions/"$SANDBOX_PYTHON_VERSION"_sandbox/bin/python" -m venv --copies /sandbox/venv
28
29
 
29
30
  ###### Codejail service code
30
- FROM minimal as code
31
+ FROM minimal AS code
31
32
  RUN git clone {{ CODEJAIL_SERVICE_REPOSITORY }} --branch {{ CODEJAIL_SERVICE_VERSION }} --depth 1 /openedx/codejailservice
32
33
  WORKDIR /openedx/codejailservice
33
34
 
34
35
  ###### Install python requirements in virtualenv
35
- FROM python as codejailservice-python-requirements
36
+ FROM python AS codejailservice-python-requirements
36
37
 
37
- ENV PATH /openedx/venv/bin:${PATH}
38
- ENV VIRTUAL_ENV /openedx/venv/
38
+ ENV PATH=/openedx/venv/bin:${PATH}
39
+ ENV VIRTUAL_ENV=/openedx/venv/
39
40
 
40
41
  COPY --from=code /openedx/codejailservice /openedx/codejailservice
41
42
  WORKDIR /openedx/codejailservice
@@ -43,16 +44,19 @@ RUN pip3 install -r requirements/base.txt
43
44
  RUN pip3 install uwsgi==2.0.21
44
45
 
45
46
  ###### Install python requirements in virtualenv
46
- FROM python as sandbox-python-requirements
47
+ FROM python AS sandbox-python-requirements
47
48
 
48
- ENV PATH /sandbox/venv/bin:${PATH}
49
- ENV VIRTUAL_ENV /sandbox/venv/
49
+ ARG EDX_PLATFORM_REPOSITORY={{ EDX_PLATFORM_REPOSITORY }}
50
+ ARG EDX_PLATFORM_VERSION={{ EDX_PLATFORM_VERSION }}
51
+
52
+ ENV PATH=/sandbox/venv/bin:${PATH}
53
+ ENV VIRTUAL_ENV=/sandbox/venv/
50
54
 
51
55
  WORKDIR /var/tmp
52
56
  RUN mkdir -p common/lib/
53
57
 
54
- COPY --from={{ DOCKER_IMAGE_OPENEDX }} /openedx/edx-platform/requirements/edx-sandbox/releases/redwood.txt redwood.txt
55
- RUN pip3 install -r redwood.txt
58
+ ADD $EDX_PLATFORM_REPOSITORY#$EDX_PLATFORM_VERSION:requirements/edx-sandbox/releases .
59
+ RUN pip3 install -r sumac.txt
56
60
 
57
61
  # Allows you to add extra pip requirements to your codejail sandbox.
58
62
  {% if CODEJAIL_EXTRA_PIP_REQUIREMENTS is defined %}
@@ -61,7 +65,7 @@ RUN pip3 install -r redwood.txt
61
65
  {% endif %}
62
66
 
63
67
  ##### Prod image
64
- FROM minimal as production
68
+ FROM minimal AS production
65
69
 
66
70
  # Install system requirements
67
71
  RUN apt update && \
@@ -76,8 +80,8 @@ COPY --from=sandbox-python-requirements /sandbox/venv /sandbox/venv
76
80
  ENV SANDBOX_ENV=/sandbox/venv
77
81
  RUN groupadd -r sandbox && useradd -m -r -g sandbox sandbox && chown -R sandbox:sandbox /sandbox
78
82
 
79
- ENV PATH /openedx/venv/bin:${PATH}
80
- ENV VIRTUAL_ENV /openedx/venv/
83
+ ENV PATH=/openedx/venv/bin:${PATH}
84
+ ENV VIRTUAL_ENV=/openedx/venv/
81
85
  WORKDIR /openedx/codejailservice
82
86
 
83
87
  EXPOSE 8550
@@ -1,4 +1,4 @@
1
- FROM golang:latest as go_compiler
1
+ FROM golang:latest AS go_compiler
2
2
 
3
3
  RUN mkdir /app
4
4
  WORKDIR /app
@@ -7,9 +7,8 @@ RUN go mod init loader
7
7
  RUN go get k8s.io/klog/v2
8
8
  RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo --ldflags '-w' -o loader .
9
9
 
10
- FROM alpine:latest
10
+ FROM alpine:3.20
11
11
 
12
- RUN apk add apparmor libapparmor --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted && \
13
- apk add --no-cache musl\>1.1.20 --repository http://dl-cdn.alpinelinux.org/alpine/edge/main/
12
+ RUN apk add apparmor libapparmor --update-cache
14
13
 
15
14
  COPY --from=go_compiler /app/loader /usr/bin/loader