def code():
# Try to create a basic list of values
x = 1
y = "hello"
z = [1, 2, 3]
return f"Basic types work: {x}, {y}, {z}"
이게 처음으로 됬음
def code():
functions = []
# Try some common built-ins
for func in ['print', 'len', 'str', 'int', 'list', 'dict', 'tuple', 'range', 'enumerate', 'globals', 'locals', 'type', 'hasattr', 'getattr']:
try:
if eval(func):
functions.append(func)
except:
pass
return f"Available functions: {functions}"
Enter your code: def code():
functions = []
# Try some common built-ins
for func in ['print', 'len', 'str', 'int', 'list', 'dict', 'tuple', 'range', 'enumerate', 'globals', 'locals', 'type', 'hasattr', 'getattr']:
try:
if eval(func):
functions.append(func)
except:
pass
return f"Available functions: {functions}"
Traceback (most recent call last):
File "/home/safe_python_executor/executor.py", line 52, in <module>
ret = e.execute_untrusted_code(code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/safe_python_executor/executor.py", line 35, in execute_untrusted_code
byte_code = compile_restricted(code, filename="<untrusted code>", mode="exec")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/RestrictedPython/compile.py", line 211, in compile_restricted
raise SyntaxError(result.errors)
SyntaxError: ('Line 7: Eval calls are not allowed.',)