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
c6dae2f1
Commit
c6dae2f1
authored
May 29, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2145 from edx/ned/codejail-slug
Ned/codejail slug
parents
42a55faf
3a030df5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
common/lib/capa/capa/capa_problem.py
+1
-0
common/lib/capa/capa/responsetypes.py
+8
-7
common/lib/capa/capa/safe_exec/safe_exec.py
+5
-2
requirements/edx/github.txt
+1
-1
No files found.
common/lib/capa/capa/capa_problem.py
View file @
c6dae2f1
...
@@ -469,6 +469,7 @@ class LoncapaProblem(object):
...
@@ -469,6 +469,7 @@ class LoncapaProblem(object):
random_seed
=
self
.
seed
,
random_seed
=
self
.
seed
,
python_path
=
python_path
,
python_path
=
python_path
,
cache
=
self
.
system
.
cache
,
cache
=
self
.
system
.
cache
,
slug
=
self
.
problem_id
,
)
)
except
Exception
as
err
:
except
Exception
as
err
:
log
.
exception
(
"Error while execing script code: "
+
all_code
)
log
.
exception
(
"Error while execing script code: "
+
all_code
)
...
...
common/lib/capa/capa/responsetypes.py
View file @
c6dae2f1
...
@@ -140,6 +140,8 @@ class LoncapaResponse(object):
...
@@ -140,6 +140,8 @@ class LoncapaResponse(object):
self
.
context
=
context
self
.
context
=
context
self
.
system
=
system
self
.
system
=
system
self
.
id
=
xml
.
get
(
'id'
)
for
abox
in
inputfields
:
for
abox
in
inputfields
:
if
abox
.
tag
not
in
self
.
allowed_inputfields
:
if
abox
.
tag
not
in
self
.
allowed_inputfields
:
msg
=
"
%
s: cannot have input field
%
s"
%
(
msg
=
"
%
s: cannot have input field
%
s"
%
(
...
@@ -286,7 +288,7 @@ class LoncapaResponse(object):
...
@@ -286,7 +288,7 @@ class LoncapaResponse(object):
}
}
try
:
try
:
safe_exec
.
safe_exec
(
code
,
globals_dict
,
python_path
=
self
.
context
[
'python_path'
])
safe_exec
.
safe_exec
(
code
,
globals_dict
,
python_path
=
self
.
context
[
'python_path'
]
,
slug
=
self
.
id
)
except
Exception
as
err
:
except
Exception
as
err
:
msg
=
'Error
%
s in evaluating hint function
%
s'
%
(
err
,
hintfn
)
msg
=
'Error
%
s in evaluating hint function
%
s'
%
(
err
,
hintfn
)
msg
+=
"
\n
See XML source line
%
s"
%
getattr
(
msg
+=
"
\n
See XML source line
%
s"
%
getattr
(
...
@@ -935,7 +937,6 @@ class CustomResponse(LoncapaResponse):
...
@@ -935,7 +937,6 @@ class CustomResponse(LoncapaResponse):
# if <customresponse> has an "expect" (or "answer") attribute then save
# if <customresponse> has an "expect" (or "answer") attribute then save
# that
# that
self
.
expect
=
xml
.
get
(
'expect'
)
or
xml
.
get
(
'answer'
)
self
.
expect
=
xml
.
get
(
'expect'
)
or
xml
.
get
(
'answer'
)
self
.
myid
=
xml
.
get
(
'id'
)
log
.
debug
(
'answer_ids=
%
s'
%
self
.
answer_ids
)
log
.
debug
(
'answer_ids=
%
s'
%
self
.
answer_ids
)
...
@@ -972,7 +973,7 @@ class CustomResponse(LoncapaResponse):
...
@@ -972,7 +973,7 @@ class CustomResponse(LoncapaResponse):
'ans'
:
ans
,
'ans'
:
ans
,
}
}
globals_dict
.
update
(
kwargs
)
globals_dict
.
update
(
kwargs
)
safe_exec
.
safe_exec
(
code
,
globals_dict
,
python_path
=
self
.
context
[
'python_path'
])
safe_exec
.
safe_exec
(
code
,
globals_dict
,
python_path
=
self
.
context
[
'python_path'
]
,
slug
=
self
.
id
)
return
globals_dict
[
'cfn_return'
]
return
globals_dict
[
'cfn_return'
]
return
check_function
return
check_function
...
@@ -981,7 +982,7 @@ class CustomResponse(LoncapaResponse):
...
@@ -981,7 +982,7 @@ class CustomResponse(LoncapaResponse):
if
not
self
.
code
:
if
not
self
.
code
:
if
answer
is
None
:
if
answer
is
None
:
log
.
error
(
"[courseware.capa.responsetypes.customresponse] missing"
log
.
error
(
"[courseware.capa.responsetypes.customresponse] missing"
" code checking script! id=
%
s"
%
self
.
my
id
)
" code checking script! id=
%
s"
%
self
.
id
)
self
.
code
=
''
self
.
code
=
''
else
:
else
:
answer_src
=
answer
.
get
(
'src'
)
answer_src
=
answer
.
get
(
'src'
)
...
@@ -1034,7 +1035,7 @@ class CustomResponse(LoncapaResponse):
...
@@ -1034,7 +1035,7 @@ class CustomResponse(LoncapaResponse):
# note that this doesn't help the "cfn" version - only the exec version
# note that this doesn't help the "cfn" version - only the exec version
self
.
context
.
update
({
self
.
context
.
update
({
# my ID
# my ID
'response_id'
:
self
.
my
id
,
'response_id'
:
self
.
id
,
# expected answer (if given as attribute)
# expected answer (if given as attribute)
'expect'
:
self
.
expect
,
'expect'
:
self
.
expect
,
...
@@ -1089,7 +1090,7 @@ class CustomResponse(LoncapaResponse):
...
@@ -1089,7 +1090,7 @@ class CustomResponse(LoncapaResponse):
# exec the check function
# exec the check function
if
isinstance
(
self
.
code
,
basestring
):
if
isinstance
(
self
.
code
,
basestring
):
try
:
try
:
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
,
cache
=
self
.
system
.
cache
)
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
,
cache
=
self
.
system
.
cache
,
slug
=
self
.
id
)
except
Exception
as
err
:
except
Exception
as
err
:
self
.
_handle_exec_exception
(
err
)
self
.
_handle_exec_exception
(
err
)
...
@@ -1813,7 +1814,7 @@ class SchematicResponse(LoncapaResponse):
...
@@ -1813,7 +1814,7 @@ class SchematicResponse(LoncapaResponse):
]
]
self
.
context
.
update
({
'submission'
:
submission
})
self
.
context
.
update
({
'submission'
:
submission
})
try
:
try
:
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
,
cache
=
self
.
system
.
cache
)
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
,
cache
=
self
.
system
.
cache
,
slug
=
self
.
id
)
except
Exception
as
err
:
except
Exception
as
err
:
msg
=
'Error
%
s in evaluating SchematicResponse'
%
err
msg
=
'Error
%
s in evaluating SchematicResponse'
%
err
raise
ResponseError
(
msg
)
raise
ResponseError
(
msg
)
...
...
common/lib/capa/capa/safe_exec/safe_exec.py
View file @
c6dae2f1
...
@@ -71,7 +71,7 @@ def update_hash(hasher, obj):
...
@@ -71,7 +71,7 @@ def update_hash(hasher, obj):
@statsd.timed
(
'capa.safe_exec.time'
)
@statsd.timed
(
'capa.safe_exec.time'
)
def
safe_exec
(
code
,
globals_dict
,
random_seed
=
None
,
python_path
=
None
,
cache
=
None
):
def
safe_exec
(
code
,
globals_dict
,
random_seed
=
None
,
python_path
=
None
,
cache
=
None
,
slug
=
None
):
"""
"""
Execute python code safely.
Execute python code safely.
...
@@ -87,6 +87,9 @@ def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None
...
@@ -87,6 +87,9 @@ def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None
to cache the execution, taking into account the code, the values of the globals,
to cache the execution, taking into account the code, the values of the globals,
and the random seed.
and the random seed.
`slug` is an arbitrary string, a description that's meaningful to the
caller, that will be used in log messages.
"""
"""
# Check the cache for a previous result.
# Check the cache for a previous result.
if
cache
:
if
cache
:
...
@@ -112,7 +115,7 @@ def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None
...
@@ -112,7 +115,7 @@ def safe_exec(code, globals_dict, random_seed=None, python_path=None, cache=None
try
:
try
:
codejail_safe_exec
(
codejail_safe_exec
(
code_prolog
+
LAZY_IMPORTS
+
code
,
globals_dict
,
code_prolog
+
LAZY_IMPORTS
+
code
,
globals_dict
,
python_path
=
python_path
,
python_path
=
python_path
,
slug
=
slug
,
)
)
except
SafeExecException
as
e
:
except
SafeExecException
as
e
:
emsg
=
e
.
message
emsg
=
e
.
message
...
...
requirements/edx/github.txt
View file @
c6dae2f1
...
@@ -9,4 +9,4 @@
...
@@ -9,4 +9,4 @@
# Our libraries:
# Our libraries:
-e git+https://github.com/edx/XBlock.git@2144a25d#egg=XBlock
-e git+https://github.com/edx/XBlock.git@2144a25d#egg=XBlock
-e git+https://github.com/edx/codejail.git@
874361f
#egg=codejail
-e git+https://github.com/edx/codejail.git@
5fb5fa0
#egg=codejail
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