INNER CODE UNIT · Python
_is_potentially_dangerous
handrew/browserpilot · browserpilot/agents/gpt_selenium_agent.py:163
def _is_potentially_dangerous(self, code_str):
"""Isaac Asimov is rolling over in his grave."""
# Check that the code doesn't try any funny business with the importing.
if "import " in code_str:
return True
# Check that the code doesn't use any of the following libraries.
blacklisted_libraries = ["shutil", "requests", "urllib"] # "os", "sys".
for library in blacklisted_libraries:
if library in code_str:
return True
# # Check that the code doesn't use any of the following functions.
# blacklisted_functions = ["open", "exec", "eval", "input", "print", "write"]
# for function in blacklisted_functions:
# if function in code_str:
# return True