diff options
| author | mo khan <mo.khan@gmail.com> | 2020-04-14 17:53:26 +0000 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-04-14 17:53:26 +0000 |
| commit | 3fdf2793726ad19d7f654fec0a9a98600d39d48f (patch) | |
| tree | f57d0fbea6e26f9722e773e8148ca00a4f82817f /lib | |
| parent | dda9e59a4a3ab471001998d0e68d67ab12b4ac69 (diff) | |
| parent | abc83e16d11ae1476f2b41ab4c2dd975cb7f1776 (diff) | |
Merge branch '213584-pip-root-certificate' into 'master'v3.7.1
Specify PIP_CERT when installing pip packages
See merge request gitlab-org/security-products/license-management!133
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/license/finder/ext/pip.rb | 6 | ||||
| -rw-r--r-- | lib/license/finder/ext/pipenv.rb | 11 | ||||
| -rw-r--r-- | lib/license/management/python.rb | 6 | ||||
| -rw-r--r-- | lib/license/management/shell.rb | 2 | ||||
| -rw-r--r-- | lib/license/management/version.rb | 2 |
5 files changed, 15 insertions, 12 deletions
diff --git a/lib/license/finder/ext/pip.rb b/lib/license/finder/ext/pip.rb index 5ef6602..084816c 100644 --- a/lib/license/finder/ext/pip.rb +++ b/lib/license/finder/ext/pip.rb @@ -35,10 +35,14 @@ module LicenseFinder def install_packages within_project_dir do shell.execute(['virtualenv -p', python_executable, '--activators=bash --seeder=app-data .venv']) - shell.sh([". .venv/bin/activate", "&&", :pip, :install, '-i', python.pip_index_url, '-r', @requirements_path]) + shell.sh([". .venv/bin/activate", "&&", pip_install_command], env: python.default_env) end end + def pip_install_command + [:pip, :install, '-v', '-i', python.pip_index_url, '-r', @requirements_path] + end + def python_executable '"$(asdf where python)/bin/python"' end diff --git a/lib/license/finder/ext/pipenv.rb b/lib/license/finder/ext/pipenv.rb index d681cc2..056b81d 100644 --- a/lib/license/finder/ext/pipenv.rb +++ b/lib/license/finder/ext/pipenv.rb @@ -5,8 +5,8 @@ module LicenseFinder def prepare return unless pipfile? - shell.execute([:pipenv, '--python', python.version], env: default_env) - shell.execute([:pipenv, :run, :pipenv, :sync, '--pypi-mirror', python.pip_index_url], env: default_env) + shell.execute([:pipenv, '--python', python.version], env: python.default_env) + shell.execute([:pipenv, :run, :pipenv, :sync, '--pypi-mirror', python.pip_index_url], env: python.default_env) end def current_packages @@ -48,12 +48,5 @@ module LicenseFinder def lockfile_hash @lockfile_hash ||= JSON.parse(IO.read(detected_package_path)) end - - def default_env - return {} unless shell.custom_certificate_installed? - return {} if ENV['PIP_CERT'] - - { 'PIP_CERT' => shell.custom_certificate_path.to_s } - end end end diff --git a/lib/license/management/python.rb b/lib/license/management/python.rb index c5f7107..b8932f9 100644 --- a/lib/license/management/python.rb +++ b/lib/license/management/python.rb @@ -50,6 +50,12 @@ module License ) end end + + def default_env + return {} unless shell.custom_certificate_installed? + + { 'PIP_CERT' => ENV.fetch('PIP_CERT', shell.custom_certificate_path.to_s) } + end end end end diff --git a/lib/license/management/shell.rb b/lib/license/management/shell.rb index 691a8ea..8850e60 100644 --- a/lib/license/management/shell.rb +++ b/lib/license/management/shell.rb @@ -33,7 +33,7 @@ module License private def expand(command) - Array(command).map(&:to_s).join(' ') + Array(command).flatten.map(&:to_s).join(' ') end def trust!(certificate) diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb index b422fd6..fe617f9 100644 --- a/lib/license/management/version.rb +++ b/lib/license/management/version.rb @@ -2,6 +2,6 @@ module License module Management - VERSION = '3.7.0' + VERSION = '3.7.1' end end |
