Repository navigation
Conversation
The /debug/run_python page let staff run Python through the sandbox to check that codejail was set up on the server. Since openedx#39382 the platform no longer runs codejail itself; it only calls codejail-service, which has its own health checks, so the page no longer tests anything the platform owns. Removes the view, its URL and template, and the ENABLE_DEBUG_RUN_PYTHON setting that turned it on. Closes part of openedx#39427 See openedx#36639 BREAKING CHANGE: The ENABLE_DEBUG_RUN_PYTHON setting and the /debug/run_python page are removed. Remove the setting from your configuration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ormsbee
left a comment
There was a problem hiding this comment.
A few small things inline. The one I'd like sorted out before this merges is the shim's BREAKING CHANGE footer, since I don't think a stale CODE_JAIL_REST_SERVICE_REMOTE_EXEC actually breaks after this. I also have a question about whether we can be more aggressive about removing calls to can_execute_unsafe_code(), but I don't consider that blocking.
Claude usage details
Claude drafted this review and ran these on 4e50a6a:
- Throwaway test of
get_remote_exec()with stale settings (xblocks-core 3.0.0,lms.envs.test): passed. Not in the branch.CODE_JAIL_REST_SERVICE_REMOTE_EXECset to the oldxmodulepath, thexblocks_contribpath from the Verawood warning, and a made-upmy_pluginpath, withsend_safe_exec_request_v0mocked.- Each one called the mocked default sender once, with no warnings and no log records. A real module with a missing function raised
AttributeError.
test_sandboxing.py, plus theunsafe_codetests intest_block_render.pyandtest_preview.py(Python 3.12, SQLite, MongoDB 7.0): 18 passed.git grepforrun_python,ENABLE_DEBUG_RUN_PYTHON,xmodule.capa.safe_execandrequirements/edx-sandbox: only a#:source reference inconf/locale/eo/LC_MESSAGES/django.po.- Shim history:
cd733fe(#38045) is inrelease/verawoodand not inrelease/ulmo. - Read the Docs check: the build was cancelled after about a minute, as were eight of the fifteen builds after it, so it doesn't look related to this branch.
Model: Claude Fable 5.2 (claude-fable-5-2)
| ) | ||
|
|
||
| # Wildcard import to expose send_safe_exec_request_v0 and any other attributes | ||
| from xblock_problem.capa.safe_exec.remote_exec import * # noqa: F403 |
There was a problem hiding this comment.
Is this really breaking for the setting? Claude ran get_remote_exec() on this branch with CODE_JAIL_REST_SERVICE_REMOTE_EXEC still pointing at xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0, and the call went to the default send_safe_exec_request_v0 anyway, with no warning and nothing logged. xblocks-core catches the ModuleNotFoundError and falls back to the default. The xblocks_contrib.problem.capa... path that the Verawood copy of this shim told people to switch to gets the same treatment.
So as far as I can tell, a stale setting keeps working after this, and what actually breaks is code that imports this module directly. Could you please reword the BREAKING CHANGE footer and the Willow note to say that? It'd be worth naming both old paths, since anyone who followed the Verawood warning has the xblocks_contrib one.
FWIW, I'd rather that fallback at least logged a warning, since a typo in the path to a custom function gets the default sender in the same silent way. But that's an xblocks-core change, and I don't want to add it to the scope of this PR.
| Returns a boolean, true if the course can run outside the sandbox. | ||
| Returns a boolean, true if the course matches COURSES_WITH_UNSAFE_CODE. | ||
|
|
||
| See the module-level `can_execute_unsafe_code` for what a match does now. |
There was a problem hiding this comment.
The other two can_execute_unsafe_code docstrings still describe the old behavior. The one on _ModuleSystemShim says it's "whether or not to allow the execution of unsafe, unsandboxed code", and the one on RuntimeShim has a "Change this if/when we need to support unsafe courses in the new runtime" comment. If we're keeping this behavior, those docstrings should probably be updated. But again, I'd be in favor of just removing calls where we can and hardcoding a False return in places where that might break XBlock backwards compatibility.
| Running course code outside the sandbox is no longer supported. When this returns | ||
| True, xblocks-core raises ImproperlyConfigured instead of running the course's Python, | ||
| so a matching course fails rather than running unsandboxed. Per-course limits are | ||
| configured on the codejail service instead. | ||
| See https://github.com/openedx/openedx-platform/issues/36639 |
There was a problem hiding this comment.
Question: Can we just kill this function entirely and update its callers to not call it, now that the question of "can I execute this unsafely" is always "no"? I think that the way this function has been re-purposed to "did you specify that you wanted to escape the sandbox for this course" is going to be confusing, and I'm not clear on what value it adds to have that distinction.
There was a problem hiding this comment.
Yea, this was a cleanup miss, once #39382 removed the setting's default we should have dropped every read of it. I removed the module-level function and both runtime.can_execute_unsafe_code properties. The method on SandboxService has to stay for now since xblocks-core's ProblemBlock still reads it, so it just returns False until openedx/xblocks-core#350 lands.
There was a problem hiding this comment.
FWIW, I think the runtime service and xmodule shim can stay and just always return False. It costs very little, and there's the possibility that there is some XBlock out there in the wild that uses it. I'd just delete it entirely from this module because I wouldn't expect XBlocks in the wild to ever import from xmodule.util.sandboxing.
There was a problem hiding this comment.
Yea, that makes sense. I put both runtime properties back and they always return False now.
The shim was added in openedx#38045 when capa moved to xblocks-core, so that deployments with CODE_JAIL_REST_SERVICE_REMOTE_EXEC pointing at the old module path kept working. It has warned since Verawood, and the default already points at the new path. Closes part of openedx#39427 Shim added in openedx#38045 BREAKING CHANGE: the xmodule.capa.safe_exec.remote_exec module is gone, so code that imports it directly breaks. A CODE_JAIL_REST_SERVICE_REMOTE_EXEC setting that still points at xmodule.capa.safe_exec.remote_exec.send_safe_exec_request_v0, or at xblocks_contrib.problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0 as the Verawood warning suggested, keeps working: xblocks-core can't import it and falls back to the default sender. Remove the override, or point it at xblock_problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4e50a6a to
cd7ff49
Compare
still read it with getattr, so a course an operator left on the list made xblocks-core raise ImproperlyConfigured for every Python-evaluated problem in it, including ones that run fine in the sandbox. A removed setting should just be ignored. Drop the module-level can_execute_unsafe_code and the setting read. The runtime.can_execute_unsafe_code properties on the module system and runtime shims stay and always return False, so XBlocks that still read them don't break. The platform's own ProblemBlock passes lambda: False to LoncapaSystem. SandboxService.can_execute_unsafe_code stays as a shim that always returns False, because xblocks-core's ProblemBlock still reads it from the sandbox service; it goes with openedx/xblocks-core#350 Closes part of openedx#39427 See openedx#36639 BREAKING CHANGE: COURSES_WITH_UNSAFE_CODE is no longer read. Courses that matched it run their Python in the codejail service like every other course, instead of failing with ImproperlyConfigured. Co-Authored-By: Claude Opus 5.5 <[email protected]>
openedx#39382 removed requirements/edx-sandbox; the sandbox's packages are defined in codejail-service now. The requirements README and the comment in the consistent-dependencies workflow still described it. The workflow still needs to watch requirements/ for the requirements/edx/*.txt exports, so only the comment changes. Closes part of openedx#39427 Co-Authored-By: Claude Opus 5.5 <[email protected]>
cd7ff49 to
a11d273
Compare
Follow-up to #39382. Closes #39427.
run_pythonview and theENABLE_DEBUG_RUN_PYTHONsetting. The platform no longer runs codejail itself, so the page doesn't test anything the platform owns.xmodule.capa.safe_exec.remote_execshim, which has warned since Verawood. ACODE_JAIL_REST_SERVICE_REMOTE_EXECsetting that still points at it, or at thexblocks_contrib.problem.capa...path the Verawood warning suggested, keeps working: xblocks-core falls back to the default sender when it can't import the configured one. What breaks is code that imports the module directly.COURSES_WITH_UNSAFE_CODE. feat!: remove local codejail #39382 removed its default and docs, butcan_execute_unsafe_codestill read it, so a course left on the list failed every Python-evaluated problem. The module-levelcan_execute_unsafe_codeis gone. The deprecatedruntime.can_execute_unsafe_codeproperties stay and always return False, so XBlocks that still read them don't break.SandboxService.can_execute_unsafe_codestays as a shim that always returns False, because xblocks-core'sProblemBlockstill reads it; Dropcan_execute_unsafe_codeand theunsafelyargument xblocks-core#350 tracks removing it.edx-sandboxfrom the requirements README and the comment in the consistent-dependencies workflow.All three removals are breaking, and each commit carries a
BREAKING CHANGEfooter. They'll go in the Willow operator notes next to the local codejail removal.