tutor-contrib-codejail 18.0.0__py2.py3-none-any.whl

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 (30) hide show
  1. tutor_contrib_codejail-18.0.0.dist-info/LICENSE +671 -0
  2. tutor_contrib_codejail-18.0.0.dist-info/METADATA +210 -0
  3. tutor_contrib_codejail-18.0.0.dist-info/RECORD +30 -0
  4. tutor_contrib_codejail-18.0.0.dist-info/WHEEL +6 -0
  5. tutor_contrib_codejail-18.0.0.dist-info/entry_points.txt +2 -0
  6. tutor_contrib_codejail-18.0.0.dist-info/top_level.txt +1 -0
  7. tutorcodejail/__about__.py +2 -0
  8. tutorcodejail/__init__.py +1 -0
  9. tutorcodejail/patches/.gitignore +0 -0
  10. tutorcodejail/patches/cms-env +4 -0
  11. tutorcodejail/patches/k8s-deployments +93 -0
  12. tutorcodejail/patches/k8s-jobs +21 -0
  13. tutorcodejail/patches/k8s-services +12 -0
  14. tutorcodejail/patches/kustomization-configmapgenerator +6 -0
  15. tutorcodejail/patches/kustomization-resources +1 -0
  16. tutorcodejail/patches/lms-env +4 -0
  17. tutorcodejail/patches/local-docker-compose-dev-services +8 -0
  18. tutorcodejail/patches/local-docker-compose-jobs-services +9 -0
  19. tutorcodejail/patches/local-docker-compose-services +13 -0
  20. tutorcodejail/plugin.py +131 -0
  21. tutorcodejail/templates/codejail/apps/.gitignore +0 -0
  22. tutorcodejail/templates/codejail/apps/config/tutor.py +18 -0
  23. tutorcodejail/templates/codejail/apps/profiles/docker-edx-sandbox +80 -0
  24. tutorcodejail/templates/codejail/build/.gitignore +0 -0
  25. tutorcodejail/templates/codejail/build/codejail/Dockerfile +92 -0
  26. tutorcodejail/templates/codejail/build/codejail_apparmor/Dockerfile +15 -0
  27. tutorcodejail/templates/codejail/k8s/.gitignore +0 -0
  28. tutorcodejail/templates/codejail/k8s/hpa.yml +18 -0
  29. tutorcodejail/templates/codejail/tasks/.gitignore +0 -0
  30. tutorcodejail/templates/codejail/tasks/codejail-apparmor/init +5 -0
@@ -0,0 +1,80 @@
1
+ #include <tunables/global>
2
+
3
+ profile docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }} flags=(attach_disconnected,mediate_deleted) {
4
+ #include <abstractions/base>
5
+
6
+ network,
7
+ capability,
8
+ file,
9
+ umount,
10
+ signal (receive) peer=unconfined,
11
+ signal (receive) peer=cri-containerd.apparmor.d,
12
+ signal (send,receive) peer=docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }},
13
+
14
+ deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
15
+ # deny write to files not in /proc/<number>/** or /proc/sys/**
16
+ deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w,
17
+ deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
18
+ deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/
19
+ deny @{PROC}/sysrq-trigger rwklx,
20
+ deny @{PROC}/mem rwklx,
21
+ deny @{PROC}/kmem rwklx,
22
+ deny @{PROC}/kcore rwklx,
23
+
24
+ deny mount,
25
+ deny /sys/[^f]*/** wklx,
26
+ deny /sys/f[^s]*/** wklx,
27
+ deny /sys/fs/[^c]*/** wklx,
28
+ deny /sys/fs/c[^g]*/** wklx,
29
+ deny /sys/fs/cg[^r]*/** wklx,
30
+ deny /sys/firmware/** rwklx,
31
+ deny /sys/kernel/security/** rwklx,
32
+
33
+ ptrace (trace,read) peer=docker-edx-sandbox-{{ CODEJAIL_SANDBOX_PYTHON_VERSION }},
34
+
35
+ /sandbox/venv/bin/python Cx -> child,
36
+ profile child flags=(attach_disconnected,mediate_deleted){
37
+ #include <abstractions/base>
38
+
39
+ #
40
+ # Python abstractions adapted from https://gitlab.com/apparmor/apparmor/-/raw/master/profiles/apparmor.d/abstractions/python
41
+ #
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
+
49
+
50
+ #
51
+ # Whitelist particiclar shared objects from the system
52
+ # python installation
53
+ #
54
+ /sandbox/venv/** mr,
55
+ /opt/pyenv/versions/{{ CODEJAIL_SANDBOX_PYTHON_VERSION }}_sandbox/** mr,
56
+ /tmp/codejail-*/ rix,
57
+ /tmp/codejail-*/** wrix,
58
+ /tmp/* wrix,
59
+
60
+ #
61
+ # Whitelist particular shared objects from the system
62
+ # python installation
63
+ #
64
+ /sandbox/venv/.config/ wrix,
65
+ /sandbox/venv/.cache/ wrix,
66
+ /sandbox/venv/.config/** wrix,
67
+ /sandbox/venv/.cache/** wrix,
68
+
69
+ # Matplot lib needs fonts to make graphs
70
+ /usr/share/fonts/ r,
71
+ /usr/share/fonts/** r,
72
+ /usr/local/share/fonts/ r,
73
+ /usr/local/share/fonts/** r,
74
+
75
+ #
76
+ # Allow access to selections from /proc
77
+ #
78
+ /proc/*/mounts r,
79
+ }
80
+ }
File without changes
@@ -0,0 +1,92 @@
1
+ FROM docker.io/ubuntu:22.04 as minimal
2
+ MAINTAINER edunext.co <contact@edunext.co>
3
+
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+ RUN apt update && \
6
+ apt install -y build-essential curl git language-pack-en llvm
7
+ ENV LC_ALL en_US.UTF-8
8
+
9
+ ###### Install python with pyenv in /opt/pyenv and create virtualenv in /openedx/venv
10
+ FROM minimal as python
11
+ # https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites
12
+ RUN apt update && \
13
+ apt install -y libssl-dev zlib1g-dev libbz2-dev \
14
+ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
15
+ xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git subversion
16
+ ENV PYENV_ROOT /opt/pyenv
17
+ RUN git clone https://github.com/pyenv/pyenv $PYENV_ROOT --branch v2.4.0 --depth 1
18
+
19
+ ARG CODEJAILSERVICE_PYTHON_VERSION=3.11.9
20
+ RUN $PYENV_ROOT/bin/pyenv install $CODEJAILSERVICE_PYTHON_VERSION
21
+
22
+ ARG SANDBOX_PYTHON_VERSION={{ CODEJAIL_SANDBOX_PYTHON_VERSION }}
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
25
+
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
28
+
29
+ ###### Codejail service code
30
+ FROM minimal as code
31
+ RUN git clone {{ CODEJAIL_SERVICE_REPOSITORY }} --branch {{ CODEJAIL_SERVICE_VERSION }} --depth 1 /openedx/codejailservice
32
+ WORKDIR /openedx/codejailservice
33
+
34
+ ###### Install python requirements in virtualenv
35
+ FROM python as codejailservice-python-requirements
36
+
37
+ ENV PATH /openedx/venv/bin:${PATH}
38
+ ENV VIRTUAL_ENV /openedx/venv/
39
+
40
+ COPY --from=code /openedx/codejailservice /openedx/codejailservice
41
+ WORKDIR /openedx/codejailservice
42
+ RUN pip3 install -r requirements/base.txt
43
+ RUN pip3 install uwsgi==2.0.21
44
+
45
+ ###### Install python requirements in virtualenv
46
+ FROM python as sandbox-python-requirements
47
+
48
+ ENV PATH /sandbox/venv/bin:${PATH}
49
+ ENV VIRTUAL_ENV /sandbox/venv/
50
+
51
+ WORKDIR /var/tmp
52
+ RUN mkdir -p common/lib/
53
+
54
+ COPY --from={{ DOCKER_IMAGE_OPENEDX }} /openedx/edx-platform/requirements/edx-sandbox/releases/redwood.txt redwood.txt
55
+ RUN pip3 install -r redwood.txt
56
+
57
+ # Allows you to add extra pip requirements to your codejail sandbox.
58
+ {% if CODEJAIL_EXTRA_PIP_REQUIREMENTS is defined %}
59
+ {% for extra_requirements in CODEJAIL_EXTRA_PIP_REQUIREMENTS %}RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install '{{ extra_requirements }}'
60
+ {% endfor %}
61
+ {% endif %}
62
+
63
+ ##### Prod image
64
+ FROM minimal as production
65
+
66
+ # Install system requirements
67
+ RUN apt update && \
68
+ apt install -y sudo
69
+
70
+ COPY --from=code /openedx/codejailservice /openedx/codejailservice
71
+ COPY --from=python /opt/pyenv /opt/pyenv
72
+ COPY --from=codejailservice-python-requirements /openedx/venv /openedx/venv
73
+ COPY --from=sandbox-python-requirements /sandbox/venv /sandbox/venv
74
+
75
+ # Setup sandbox
76
+ ENV SANDBOX_ENV=/sandbox/venv
77
+ RUN groupadd -r sandbox && useradd -m -r -g sandbox sandbox && chown -R sandbox:sandbox /sandbox
78
+
79
+ ENV PATH /openedx/venv/bin:${PATH}
80
+ ENV VIRTUAL_ENV /openedx/venv/
81
+ WORKDIR /openedx/codejailservice
82
+
83
+ EXPOSE 8550
84
+ CMD uwsgi \
85
+ --http 0.0.0.0:8550 \
86
+ --thunder-lock \
87
+ --single-interpreter \
88
+ --enable-threads \
89
+ --processes=${UWSGI_WORKERS:-2} \
90
+ --buffer-size=8192 \
91
+ --max-requests=1000 \
92
+ --wsgi-file /openedx/codejailservice/wsgi.py
@@ -0,0 +1,15 @@
1
+ FROM golang:latest as go_compiler
2
+
3
+ RUN mkdir /app
4
+ WORKDIR /app
5
+ ADD https://raw.githubusercontent.com/kubernetes/kubernetes/master/test/images/apparmor-loader/loader.go loader.go
6
+ RUN go mod init loader
7
+ RUN go get k8s.io/klog/v2
8
+ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo --ldflags '-w' -o loader .
9
+
10
+ FROM alpine:latest
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/
14
+
15
+ COPY --from=go_compiler /app/loader /usr/bin/loader
File without changes
@@ -0,0 +1,18 @@
1
+ {%- if CODEJAIL_ENABLE_HPA %}
2
+ apiVersion: autoscaling/v1
3
+ kind: HorizontalPodAutoscaler
4
+ metadata:
5
+ name: codejail
6
+ labels:
7
+ app.kubernetes.io/name: codejail
8
+ spec:
9
+ scaleTargetRef:
10
+ apiVersion: apps/v1
11
+ kind: Deployment
12
+ name: codejailservice
13
+ minReplicas: {{ CODEJAIL_MIN_REPLICAS }}
14
+ maxReplicas: {{ CODEJAIL_MAX_REPLICAS }}
15
+ {%- if CODEJAIL_AVG_CPU > 0 %}
16
+ targetCPUUtilizationPercentage: {{ CODEJAIL_AVG_CPU }}
17
+ {%- endif %}
18
+ {%- endif %}
File without changes
@@ -0,0 +1,5 @@
1
+ if [ "$SKIP_INIT" == "True" ]; then
2
+ echo "Skipped AppArmor initialization"
3
+ else
4
+ /usr/bin/loader -logtostderr -v=2 /profiles
5
+ fi