1
0
forked from VimPlug/jedi

Make sure that you can select virtualenvs more precisely, fixes #1407

This commit is contained in:
Dave Halter
2019-12-13 21:00:34 +01:00
parent 6b9add4264
commit 621e280451

View File

@@ -261,25 +261,28 @@ def find_virtualenvs(paths=None, **kwargs):
""" """
:param paths: A list of paths in your file system to be scanned for :param paths: A list of paths in your file system to be scanned for
Virtualenvs. It will search in these paths and potentially execute the Virtualenvs. It will search in these paths and potentially execute the
Python binaries. Also the VIRTUAL_ENV variable will be checked if it Python binaries.
contains a valid Virtualenv. And CONDA_PREFIX will be checked to see
if it contains a valid conda environment.
:param safe: Default True. In case this is False, it will allow this :param safe: Default True. In case this is False, it will allow this
function to execute potential `python` environments. An attacker might function to execute potential `python` environments. An attacker might
be able to drop an executable in a path this function is searching by be able to drop an executable in a path this function is searching by
default. If the executable has not been installed by root, it will not default. If the executable has not been installed by root, it will not
be executed. be executed.
:param use_environment_vars: Default True. If True, the VIRTUAL_ENV
variable will be checked if it contains a valid VirtualEnv.
CONDA_PREFIX will be checked to see if it contains a valid conda
environment.
:yields: :class:`Environment` :yields: :class:`Environment`
""" """
def py27_comp(paths=None, safe=True): def py27_comp(paths=None, safe=True, use_environment_vars=True):
if paths is None: if paths is None:
paths = [] paths = []
_used_paths = set() _used_paths = set()
# Using this variable should be safe, because attackers might be able if use_environment_vars:
# to drop files (via git) but not environment variables. # Using this variable should be safe, because attackers might be
# able to drop files (via git) but not environment variables.
virtual_env = _get_virtual_env_from_var() virtual_env = _get_virtual_env_from_var()
if virtual_env is not None: if virtual_env is not None:
yield virtual_env yield virtual_env