Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ compile-requirements: ## Regenerate uv.lock for the root project and all uv sub-
@# independent of the root project's dependency graph) before exporting any
@# compat file below, so a failure in one halts the whole target before
@# anything downstream of it is (re)generated.
@for d in requirements/edx-sandbox scripts/xblock scripts/user_retirement scripts/structures_pruning; do \
@for d in scripts/xblock scripts/user_retirement scripts/structures_pruning; do \
echo ; \
echo "== $$d ===============================" ; \
uv run --no-project --isolated --with edx-lint edx_lint write_uv_constraints $$d/pyproject.toml && \
Expand Down Expand Up @@ -126,13 +126,6 @@ compile-requirements: ## Regenerate uv.lock for the root project and all uv sub-
uv export --frozen --no-hashes --group development --group ci --no-emit-project; \
} > requirements/edx/development.txt

@# requirements/edx-sandbox, scripts/xblock: single compat export, no dependency-groups.
@{ \
echo "# GENERATED FILE, DO NOT EDIT DIRECTLY."; \
echo "# Compatibility export for anyone still 'pip install -r requirements/edx-sandbox/base.txt'"; \
echo "# directly instead of using uv. Source of truth: requirements/edx-sandbox/pyproject.toml / uv.lock."; \
(cd requirements/edx-sandbox && uv export --frozen --no-hashes --no-emit-project); \
} > requirements/edx-sandbox/base.txt
@{ \
echo "# GENERATED FILE, DO NOT EDIT DIRECTLY."; \
echo "# Compatibility export for anyone still 'pip install -r scripts/xblock/requirements.txt'"; \
Expand Down
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ Language Packages:
Codejail Setup
--------------

As a part of the baremetal setup, you will need to configure your system to
work properly with codejail. See the `codejail installation steps`_ for more
details.
While not strictly required, some components of the platform require sandboxing
capabilites. Such sandboxing is achieved through the use of a remote REST
service `codejail-service`_.

.. _codejail installation steps: https://github.com/openedx/codejail?tab=readme-ov-file#installation
Instructions on how to deploy such service can be found in https://github.com/openedx/codejail-service/blob/main/docs/deployment.rst

.. _codejail-service: https://github.com/openedx/codejail-service/blob/main/docs/deployment.rst

Build Steps
-----------
Expand Down
7 changes: 0 additions & 7 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@ def make_lms_template_path(settings):
# Detects user-requested locale from 'accept-language' header in http request
'django.middleware.locale.LocaleMiddleware',

'codejail.django_integration.ConfigureCodeJailMiddleware',

# for expiring inactive sessions
'openedx.core.djangoapps.session_inactivity_timeout.middleware.SessionInactivityTimeout',

Expand Down Expand Up @@ -478,11 +476,6 @@ def make_lms_template_path(settings):

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

#################### Python sandbox ############################################

# Needs to be non-zero so that jailed code can use it as their temp directory.(1MiB in bytes)
CODE_JAIL['limits']['FSIZE'] = 1048576 # noqa: F405

############################ DJANGO_BUILTINS ################################

COURSE_IMPORT_EXPORT_BUCKET = ''
Expand Down
22 changes: 0 additions & 22 deletions cms/envs/mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,6 @@ CLOSEST_CLIENT_IP_FROM_HEADERS:
- index: 0
name: CF-Connecting-IP
CMS_BASE: studio.localhost
CODE_JAIL:
limit_overrides:
codejail_expanded_limits:
CPU: 10
FSIZE: 2097152
PROXY: 1
REALTIME: 60
VMEM: 1073741824
course-v1:Org+Course+Run:
CPU: 5
FSIZE: 5
PROXY: 5
REALTIME: 5
VMEM: 5
limits:
CPU: 2
FSIZE: 1048576
PROXY: 1
REALTIME: 6
VMEM: 536870912
python_bin: /edx/app/edxapp/venvs/edxapp-sandbox/bin/python
user: sandbox
COMMENTS_SERVICE_KEY: test_COMMENTS_SERVICE_KEY
COMMENTS_SERVICE_URL: https://forum.localhost
COMPLETION_VIDEO_COMPLETE_PERCENTAGE: 0.9
Expand Down
2 changes: 0 additions & 2 deletions lms/djangoapps/courseware/tests/test_submitting_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from django.urls import reverse
from django.utils.timezone import now
from submissions import api as submissions_api
from xblock_problem.capa.testing.codejail import UseUnsafeCodejail
from xblock_problem.capa.testing.response_xml_factory import (
CodeResponseXMLFactory,
CustomResponseXMLFactory,
Expand Down Expand Up @@ -816,7 +815,6 @@ def test_three_files(self, mock_xqueue_post):
self.assertEqual(list(kwargs['files'].keys()), filenames.split()) # noqa: PT009


@UseUnsafeCodejail()
class TestPythonGradedResponse(TestSubmittingProblems):
"""
Check that we can submit a schematic and custom response, and it answers properly.
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/debug/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import pprint
import traceback

from codejail.safe_exec import safe_exec
from django.contrib.auth.decorators import login_required
from django.http import Http404, HttpResponse
from django.utils.html import escape
from django.views.decorators.csrf import ensure_csrf_cookie
from xblock_problem.capa.safe_exec import safe_exec

from common.djangoapps.edxmako.shortcuts import render_to_response
from openedx.core.djangolib.markup import HTML
Expand Down
2 changes: 0 additions & 2 deletions lms/djangoapps/instructor_task/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from django.test.utils import override_settings
from django.urls import reverse
from xblock_problem.capa.responsetypes import StudentInputError
from xblock_problem.capa.testing.codejail import UseUnsafeCodejail
from xblock_problem.capa.testing.response_xml_factory import CodeResponseXMLFactory, CustomResponseXMLFactory

from common.test.utils import assert_dict_contains_subset
Expand Down Expand Up @@ -73,7 +72,6 @@ def _assert_task_failure(self, entry_id, task_type, problem_url_name, expected_m

@ddt.ddt
@override_settings(RATELIMIT_ENABLE=False)
@UseUnsafeCodejail()
class TestRescoringTask(TestIntegrationTask):
"""
Integration-style tests for rescoring problems in a background task.
Expand Down
26 changes: 0 additions & 26 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,31 +1018,6 @@

#################### Python sandbox ############################################

CODE_JAIL = {
# from https://github.com/openedx/codejail/blob/master/codejail/django_integration.py#L24, '' should be same as None
'python_bin': '/edx/app/edxapp/venvs/edxapp-sandbox/bin/python',
# User to run as in the sandbox.
'user': 'sandbox',

# Configurable limits.
'limits': {
# How many CPU seconds can jailed code use?
'CPU': 1,
# Limit the memory of the jailed process to something high but not
# infinite (512MiB in bytes)
'VMEM': 536870912,
# Time in seconds that the jailed process has to run.
'REALTIME': 3,
'PROXY': 0,
},

# Overrides to default configurable 'limits' (above).
# Keys should be course run ids (or, in the special case of code running
# on the /debug/run_python page, the key is 'debug_run_python').
# Values should be dictionaries that look like 'limits'.
"limit_overrides": {},
}

# .. setting_name: PYTHON_LIB_FILENAME
# .. setting_default: python_lib.zip
# .. setting_description: Name of the course file to make available to code in
Expand Down Expand Up @@ -1307,7 +1282,6 @@
'django.middleware.locale.LocaleMiddleware',

'lms.djangoapps.discussion.django_comment_client.utils.ViewNameMiddleware',
'codejail.django_integration.ConfigureCodeJailMiddleware',

# for expiring inactive sessions
'openedx.core.djangoapps.session_inactivity_timeout.middleware.SessionInactivityTimeout',
Expand Down
22 changes: 0 additions & 22 deletions lms/envs/mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,6 @@ CHAT_COMPLETION_MAX_TOKENS: 16385
CHAT_COMPLETION_RESPONSE_TOKENS: 1000
CLOSEST_CLIENT_IP_FROM_HEADERS: []
CMS_BASE: studio-deploy_host
CODE_JAIL:
limit_overrides:
codejail_expanded_limits:
CPU: 5
FSIZE: 5
PROXY: 5
REALTIME: 5
VMEM: 5
course-v1:Org+Course+Run:
CPU: 5
FSIZE: 5
PROXY: 5
REALTIME: 5
VMEM: 5
limits:
CPU: 1
FSIZE: 1048576
PROXY: 0
REALTIME: 3
VMEM: 536870912
python_bin: /edx/app/edxapp/venvs/edxapp-sandbox/bin/python
user: sandbox
COMMENTS_SERVICE_KEY: password
COMMENTS_SERVICE_URL: http://localhost:18080
COMMERCE_COORDINATOR_REFUND_PATH: /lms/refund/
Expand Down
48 changes: 7 additions & 41 deletions openedx/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2243,54 +2243,20 @@ def add_optional_apps(optional_apps, installed_apps):

############################## Python sandbox ##############################

CODE_JAIL = {
# from https://github.com/openedx/codejail/blob/master/codejail/django_integration.py#L24, '' should be same as None
'python_bin': '/edx/app/edxapp/venvs/edxapp-sandbox/bin/python',
# User to run as in the sandbox.
'user': 'sandbox',

# Configurable limits.
'limits': {
# How many CPU seconds can jailed code use?
'CPU': 1,
# Limit the memory of the jailed process to something high but not
# infinite (512MiB in bytes)
'VMEM': 536870912,
# Time in seconds that the jailed process has to run.
'REALTIME': 3,
'PROXY': 0,
},

# Overrides to default configurable 'limits' (above).
# Keys should be course run ids (or, in the special case of code running
# on the /debug/run_python page, the key is 'debug_run_python').
# Values should be dictionaries that look like 'limits'.
"limit_overrides": {},
}

# Some courses are allowed to run unsafe code. This is a list of regexes, one
# of them must match the course id for that course to run unsafe code.
#
# For example:
#
# COURSES_WITH_UNSAFE_CODE = [
# r"Harvard/XY123.1/.*"
# ]
COURSES_WITH_UNSAFE_CODE = []

# Code jail REST service
ENABLE_CODEJAIL_REST_SERVICE = False
# CodeJail REST service

# .. setting_name: CODE_JAIL_REST_SERVICE_REMOTE_EXEC
# .. setting_default: 'xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
# .. setting_default: 'xblock_problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
# .. setting_description: Set the python package.module.function that is reponsible of
# calling the remote service in charge of jailed code execution
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = 'xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0'
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = 'xblock_problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0'

# .. setting_name: CODE_JAIL_REST_SERVICE_HOST
# .. setting_default: 'http://127.0.0.1:8550'
# .. setting_description: Set the codejail remote service host
CODE_JAIL_REST_SERVICE_HOST = 'http://127.0.0.1:8550'
# .. setting_default: None
# .. setting_description: Set the codejail remote service host. When not set problem blocks may return an
# ImproperlyConfigured error.
CODE_JAIL_REST_SERVICE_HOST = None

# .. setting_name: CODE_JAIL_REST_SERVICE_CONNECT_TIMEOUT
# .. setting_default: 0.5
Expand Down
6 changes: 6 additions & 0 deletions openedx/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def make_staticfile_dirs(settings):

DEFAULT_MOBILE_AVAILABLE = True

# Execute Codejail code locally in tests instead of calling a remote service.
CODE_JAIL_REST_SERVICE_HOST = "http://localhost:8550"
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = (
"xblock_problem.capa.testing.codejail.send_safe_exec_request_locally"
)

# Override production settings for testing
AWS_QUERYSTRING_AUTH = False
AWS_S3_CUSTOM_DOMAIN = "SET-ME-PLEASE (ex. bucket-name.s3.amazonaws.com)"
Expand Down
116 changes: 0 additions & 116 deletions requirements/edx-sandbox/README.rst

This file was deleted.

Loading
Loading