Skip to content
Merged
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
2 changes: 2 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,5 @@
'HONOR': 'honor',
'PRIVACY': 'privacy_edx',
}

COURSES_WITH_UNSAFE_CODE = []
4 changes: 3 additions & 1 deletion common/djangoapps/util/sandboxing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def can_execute_unsafe_code(course_id):
"""
# To decide if we can run unsafe code, we check the course id against
# a list of regexes configured on the server.
for regex in settings.COURSES_WITH_UNSAFE_CODE:
# If this is not defined in the environment variables then default to the most restrictive, which
# is 'no unsafe courses'
for regex in getattr(settings, 'COURSES_WITH_UNSAFE_CODE', []):
if re.match(regex, course_id):
return True
return False
7 changes: 7 additions & 0 deletions common/djangoapps/util/tests/test_sandboxing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def test_sandbox_inclusion(self):
"""
self.assertTrue(can_execute_unsafe_code('edX/full/2012_Fall'))
self.assertTrue(can_execute_unsafe_code('edX/full/2013_Spring'))

def test_courses_with_unsafe_code_default(self):
"""
Test that the default setting for COURSES_WITH_UNSAFE_CODE is an empty setting, e.g. we don't use @override_settings in these tests
"""
self.assertFalse(can_execute_unsafe_code('edX/full/2012_Fall'))
self.assertFalse(can_execute_unsafe_code('edX/full/2013_Spring'))