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
d7ea1daf
Commit
d7ea1daf
authored
May 02, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On second thought, make can_execute_unsafe_code a function returning a boolean.
parent
f1fac732
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/capa/capa/tests/__init__.py
+1
-1
common/lib/capa/capa/tests/test_responsetypes.py
+2
-2
common/lib/xmodule/xmodule/x_module.py
+4
-4
No files found.
common/lib/capa/capa/responsetypes.py
View file @
d7ea1daf
...
...
@@ -504,7 +504,7 @@ class JavascriptResponse(LoncapaResponse):
def
call_node
(
self
,
args
):
# Node.js code is un-sandboxed. If the XModuleSystem says we aren't
# allowed to run unsafe code, then stop now.
if
not
self
.
system
.
can_execute_unsafe_code
:
if
not
self
.
system
.
can_execute_unsafe_code
()
:
raise
LoncapaProblemError
(
"Execution of unsafe Javascript code is not allowed."
)
subprocess_args
=
[
"node"
]
...
...
common/lib/capa/capa/tests/__init__.py
View file @
d7ea1daf
...
...
@@ -40,7 +40,7 @@ def test_system():
node_path
=
os
.
environ
.
get
(
"NODE_PATH"
,
"/usr/local/lib/node_modules"
),
anonymous_student_id
=
'student'
,
cache
=
None
,
can_execute_unsafe_code
=
False
,
can_execute_unsafe_code
=
lambda
:
False
,
)
return
the_system
...
...
common/lib/capa/capa/tests/test_responsetypes.py
View file @
d7ea1daf
...
...
@@ -747,7 +747,7 @@ class JavascriptResponseTest(ResponseTest):
os
.
system
(
"coffee -c
%
s"
%
(
coffee_file_path
))
system
=
test_system
()
system
.
can_execute_unsafe_code
=
True
system
.
can_execute_unsafe_code
=
lambda
:
True
problem
=
self
.
build_problem
(
system
=
system
,
generator_src
=
"test_problem_generator.js"
,
...
...
@@ -765,7 +765,7 @@ class JavascriptResponseTest(ResponseTest):
# If the system says to disallow unsafe code execution, then making
# this problem will raise an exception.
system
=
test_system
()
system
.
can_execute_unsafe_code
=
False
system
.
can_execute_unsafe_code
=
lambda
:
False
with
self
.
assertRaises
(
LoncapaProblemError
):
problem
=
self
.
build_problem
(
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
d7ea1daf
...
...
@@ -702,7 +702,7 @@ class ModuleSystem(object):
open_ended_grading_interface
=
None
,
s3_interface
=
None
,
cache
=
None
,
can_execute_unsafe_code
=
Fals
e
,
can_execute_unsafe_code
=
Non
e
,
):
'''
Create a closure around the system environment.
...
...
@@ -750,8 +750,8 @@ class ModuleSystem(object):
.get(key) returns an object from the cache or None.
.set(key, value, timeout_secs=None) stores a value in the cache with a timeout.
can_execute_unsafe_code - A
boolean, whether or not to allow the execution
of unsafe, unsandboxed code.
can_execute_unsafe_code - A
function returning a boolean, whether or
not to allow the execution
of unsafe, unsandboxed code.
'''
self
.
ajax_url
=
ajax_url
...
...
@@ -778,7 +778,7 @@ class ModuleSystem(object):
self
.
s3_interface
=
s3_interface
self
.
cache
=
cache
or
DoNothingCache
()
self
.
can_execute_unsafe_code
=
can_execute_unsafe_code
self
.
can_execute_unsafe_code
=
can_execute_unsafe_code
or
(
lambda
:
False
)
def
get
(
self
,
attr
):
''' provide uniform access to attributes (like etree).'''
...
...
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