Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
40bb70e9
Commit
40bb70e9
authored
Mar 17, 2015
by
Jonathan Piacenti
Committed by
Brian Wilson
Mar 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of to_deprecated_string in sandbox regex check.
parent
5f6ee428
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
common/djangoapps/util/sandboxing.py
+1
-1
common/djangoapps/util/tests/test_sandboxing.py
+6
-2
No files found.
common/djangoapps/util/sandboxing.py
View file @
40bb70e9
...
@@ -25,7 +25,7 @@ def can_execute_unsafe_code(course_id):
...
@@ -25,7 +25,7 @@ def can_execute_unsafe_code(course_id):
# To others using this: the code as-is is brittle and likely to be changed in the future,
# To others using this: the code as-is is brittle and likely to be changed in the future,
# as per the TODO, so please consider carefully before adding more values to COURSES_WITH_UNSAFE_CODE
# as per the TODO, so please consider carefully before adding more values to COURSES_WITH_UNSAFE_CODE
for
regex
in
getattr
(
settings
,
'COURSES_WITH_UNSAFE_CODE'
,
[]):
for
regex
in
getattr
(
settings
,
'COURSES_WITH_UNSAFE_CODE'
,
[]):
if
re
.
match
(
regex
,
course_id
.
to_deprecated_string
(
)):
if
re
.
match
(
regex
,
unicode
(
course_id
)):
return
True
return
True
return
False
return
False
...
...
common/djangoapps/util/tests/test_sandboxing.py
View file @
40bb70e9
...
@@ -3,6 +3,7 @@ Tests for sandboxing.py in util app
...
@@ -3,6 +3,7 @@ Tests for sandboxing.py in util app
"""
"""
from
django.test
import
TestCase
from
django.test
import
TestCase
from
opaque_keys.edx.locator
import
LibraryLocator
from
util.sandboxing
import
can_execute_unsafe_code
from
util.sandboxing
import
can_execute_unsafe_code
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
...
@@ -12,12 +13,13 @@ class SandboxingTest(TestCase):
...
@@ -12,12 +13,13 @@ class SandboxingTest(TestCase):
"""
"""
Test sandbox whitelisting
Test sandbox whitelisting
"""
"""
@override_settings
(
COURSES_WITH_UNSAFE_CODE
=
[
'edX/full/.*'
])
@override_settings
(
COURSES_WITH_UNSAFE_CODE
=
[
'edX/full/.*'
,
'library:v1-edX+.*'
])
def
test_sandbox_exclusion
(
self
):
def
test_sandbox_exclusion
(
self
):
"""
"""
Test to make sure that a non-match returns false
Test to make sure that a non-match returns false
"""
"""
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'notful'
,
'empty'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'notful'
,
'empty'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
LibraryLocator
(
'edY'
,
'test_bank'
)))
@override_settings
(
COURSES_WITH_UNSAFE_CODE
=
[
'edX/full/.*'
])
@override_settings
(
COURSES_WITH_UNSAFE_CODE
=
[
'edX/full/.*'
])
def
test_sandbox_inclusion
(
self
):
def
test_sandbox_inclusion
(
self
):
...
@@ -26,10 +28,12 @@ class SandboxingTest(TestCase):
...
@@ -26,10 +28,12 @@ class SandboxingTest(TestCase):
"""
"""
self
.
assertTrue
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2012_Fall'
)))
self
.
assertTrue
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2012_Fall'
)))
self
.
assertTrue
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2013_Spring'
)))
self
.
assertTrue
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2013_Spring'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
LibraryLocator
(
'edX'
,
'test_bank'
)))
def
test_courses_with_unsafe_code_default
(
self
):
def
test_course
like
s_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
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
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2012_Fall'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2012_Fall'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2013_Spring'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2013_Spring'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
LibraryLocator
(
'edX'
,
'test_bank'
)))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment