refactor(validate.py): filter function objects by filename to ensure they are from the evaluated string
This commit is contained in:
parent
3b52cd0e6b
commit
a0da9c6111
1 changed files with 6 additions and 1 deletions
|
|
@ -59,7 +59,12 @@ def eval_function(function_string: str):
|
|||
# Execute the code string in the new namespace
|
||||
exec(function_string, namespace)
|
||||
function_object = next(
|
||||
(obj for name, obj in namespace.items() if isinstance(obj, types.FunctionType)),
|
||||
(
|
||||
obj
|
||||
for name, obj in namespace.items()
|
||||
if isinstance(obj, types.FunctionType)
|
||||
and obj.__code__.co_filename == "<string>"
|
||||
),
|
||||
None,
|
||||
)
|
||||
if function_object is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue