aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar hargoniX <[email protected]>2018-12-29 16:07:48 +0100
committerGravatar hargoniX <[email protected]>2018-12-29 16:07:48 +0100
commit4347dab4cd9fd285423e3b6b5959c905599b79a3 (patch)
tree4c300976db39ebe29cad8e79c1e3ac3f32538fe1
parentUpgrades Pipfile.lock to use requests 2.20.1, fixes CVE-2018-18074 (#2) (diff)
implementing repl like evaluation, the code doesnt work inside docker yet because its excluding parts of the stdlib from the venv for some reasonrepl-like
-rw-r--r--executor.py12
-rw-r--r--snekbox.py2
2 files changed, 13 insertions, 1 deletions
diff --git a/executor.py b/executor.py
new file mode 100644
index 0000000..713412b
--- /dev/null
+++ b/executor.py
@@ -0,0 +1,12 @@
+import sys
+import ast
+
+
+def main():
+ code = sys.argv[1]
+ tree = ast.parse(code)
+ fake_interactive_tree = ast.Interactive()
+ fake_interactive_tree.body = tree.body
+ exec(compile(fake_interactive_tree, "<input>", "single"), {}, {})
+
+main() \ No newline at end of file
diff --git a/snekbox.py b/snekbox.py
index ddde563..aa9747d 100644
--- a/snekbox.py
+++ b/snekbox.py
@@ -44,7 +44,7 @@ class Snekbox(object):
'--cgroup_pids_max=1',
'--cgroup_mem_max=52428800',
'--quiet', '--',
- self.python_binary, '-ISq', '-c', cmd]
+ self.python_binary, '-ISq', '/snekbox/executor.py', cmd]
try:
proc = subprocess.Popen(args,
stdin=subprocess.PIPE,