-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Confirmation
- I confirm that I am a maintainer and so can use this template. If I am not, I understand this issue will be closed and I will be asked to use a different template.
Issue body
Right now, all code executors under python/packages/autogen-ext/src/autogen_ext/code_executors are defaulting to "." -- the current directory, as the working directory for reading and writing files.
This introduces a security issue as the current directory may contain code files and other data you don't want to expose to a model.
To fix this, the code executors' constructor parameter's default for work_dir should be None, and a temp directory should be created upon the start() method is called, and the temp directory is closed when stop() method is called.
For backward compatibility for LocalCommandLineExecutor and ACADynamicSessionsCodeExecutor, which didn't have start() and stop() methods prior to #6040, we should keep using "." as the default work directory if the start() method was not called and work directory was not provided by the user, and emit a DeprecationWarning to reminder user of the best practice.
For temporary directory, see Python's tempfile: https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryDirectory