Skip to content

Commit 3a36b8d

Browse files
stsnellwesterhof
authored andcommitted
YDA-7295: update pip3 versions
Ensure we check the package hash when upgrading because server verification in older pip version has security issues.
1 parent 28a9d4b commit 3a36b8d

11 files changed

Lines changed: 69 additions & 19 deletions

File tree

‎docker/images/yoda_eus/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ RUN useradd yodadeployment && \
5959
COPY yoda-external-user-service-vhost.conf /etc/apache2/sites-available/003-yoda-eus-vhost.conf
6060
RUN ln -s /etc/apache2/sites-available/003-yoda-eus-vhost.conf /etc/apache2/sites-enabled/003-yoda-eus-vhost.conf
6161
RUN virtualenv --python /usr/bin/python3 /var/www/extuser/yoda-external-user-service/venv && \
62-
/var/www/extuser/yoda-external-user-service/venv/bin/pip3 install --no-cache-dir pip==25.0 && \
6362
/var/www/extuser/yoda-external-user-service/venv/bin/pip3 install --no-cache-dir virtualenv==20.28.0 && \
6463
/var/www/extuser/yoda-external-user-service/venv/bin/python3 -m virtualenv /var/www/extuser/yoda-external-user-service/venv && \
64+
/var/www/extuser/yoda-external-user-service/venv/bin/pip3 install --no-cache-dir pip==26.2.2 && \
6565
/var/www/extuser/yoda-external-user-service/venv/bin/pip3 install --no-cache-dir /var/www/extuser/yoda-external-user-service
6666

6767
# Make copy of data on volumes that can optionally be bind mounted, so the container init script

‎docker/images/yoda_irods_icat/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ COPY irods_environment.json /var/lib/irods/.irods/irods_environment.json
111111
# Install and configure rulesets
112112
RUN git clone -b ${YODA_RULESET_BRANCH} ${YODA_RULESET_REPO} /etc/irods/yoda-ruleset
113113
# hadolint ignore=DL3004
114-
RUN sudo -u irods python3 -m pip --no-cache-dir install --user --break-system-packages pip==25.0 && \
114+
RUN sudo -u irods python3 -m pip --no-cache-dir install --user --break-system-packages pip==26.2.2 && \
115115
sudo -u irods python3 -m pip --no-cache-dir install --user --break-system-packages -r /etc/irods/yoda-ruleset/requirements.txt && \
116116
sudo -u irods python3 -m pip install --user --break-system-packages python-irodsclient==3.3.0 && \
117117
sudo -u irods python3 -m pip install --user --break-system-packages psutil==6.1.0

‎docker/images/yoda_portal/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ RUN mkdir -p /var/www/yoda/config && \
5353
COPY yoda-portal-vhost.conf /etc/apache2/sites-available/001-yoda-portal-vhost.conf
5454
RUN ln -s /etc/apache2/sites-available/001-yoda-portal-vhost.conf /etc/apache2/sites-enabled/001-yoda-portal-vhost.conf
5555
RUN virtualenv --python /usr/bin/python3 /var/www/yoda/venv && \
56-
/var/www/yoda/venv/bin/pip3 install --no-cache-dir pip==25.0 && \
56+
/var/www/yoda/venv/bin/pip3 install --no-cache-dir pip==26.2.2 && \
5757
/var/www/yoda/venv/bin/pip3 install --no-cache-dir -r /var/www/yoda/requirements.txt
5858

5959
# Make copy of data on volumes that can optionally be bind mounted, so the container init script

‎docker/images/yoda_public/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ RUN mkdir -p /var/www/moai /var/www/moai/metadata && \
5050
chmod 0755 /var/www/moai /var/www/moai/metadata && \
5151
chown -R yodadeployment:yodadeployment /var/www/moai && \
5252
virtualenv --python /usr/bin/python3 /var/www/moai/yoda-moai/venv && \
53-
/var/www/moai/yoda-moai/venv/bin/pip3 install --no-cache-dir pip==26.0.1
53+
/var/www/moai/yoda-moai/venv/bin/pip3 install --no-cache-dir pip==26.2.2
5454

5555
## Install PySQLite3 for MOAI
5656
ENV C_INCLUDE_PATH /usr/include/python3.12:/usr/include

‎docker/images/yoda_web_mock/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ COPY --chown=yodadeployment:yodadeployment sram_mock.json /var/www/webmock/sram/
4949
COPY yoda-web-mock-vhost.conf /etc/apache2/sites-available/yoda-web-mock-vhost.conf
5050
RUN ln -s /etc/apache2/sites-available/yoda-web-mock-vhost.conf /etc/apache2/sites-enabled/yoda-web-mock-vhost.conf
5151
RUN virtualenv --python /usr/bin/python3 /var/www/webmock/venv && \
52-
/var/www/webmock/venv/bin/pip3 install --no-cache-dir pip==25.0 && \
5352
/var/www/webmock/venv/bin/pip3 install --no-cache-dir virtualenv==20.28.0 && \
5453
/var/www/webmock/venv/bin/python3 -m virtualenv /var/www/webmock/venv && \
54+
/var/www/webmock/venv/bin/pip3 install --no-cache-dir pip==26.2.2 && \
5555
/var/www/webmock/venv/bin/pip3 install --no-cache-dir -e /var/www/webmock/yoda-web-mock
5656

5757
# Make copy of data on volumes that can optionally be bind mounted, so the container init script

‎roles/python3/defaults/main.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# copyright Utrecht University
3+
4+
# pip version to use for Yoda virtual environments, we need to use a hash
5+
# because certificate validation may be compromised in older pip versions.
6+
python3_venv_pip_version: "26.2.2 --hash=sha256:fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70"
7+
python3_venv_pip_requirements: /usr/local/share/yoda/venv-pip-requirements.txt

‎roles/python3/tasks/main-tasks.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,22 @@
99
- name: Install Python 3 for Debian family
1010
ansible.builtin.include_tasks: install-debian.yml
1111
when: ansible_facts['os_family'] == 'Debian'
12+
13+
14+
- name: Ensure directory for Yoda Python requirements exists
15+
ansible.builtin.file:
16+
path: "{{ python3_venv_pip_requirements | dirname }}"
17+
state: directory
18+
owner: root
19+
group: root
20+
mode: '0755'
21+
22+
23+
- name: Ensure hash-pinned pip requirements for virtual environments are present
24+
ansible.builtin.copy:
25+
content: |
26+
pip=={{ python3_venv_pip_version }}
27+
dest: "{{ python3_venv_pip_requirements }}"
28+
owner: root
29+
group: root
30+
mode: '0644'

‎roles/yoda_external_user_service/tasks/main.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,11 @@
207207
creates: "/var/www/extuser/yoda-external-user-service/venv/bin/activate_this.py"
208208

209209

210-
- name: Upgrade pip and virtualenv in Yoda EUS virtual environment
210+
- name: Ensure virtualenv is installed in Yoda EUS virtual environment
211211
become_user: '{{ yoda_deployment_user }}'
212212
become: true
213213
ansible.builtin.pip:
214-
name:
215-
- pip==25.0
216-
- virtualenv==20.28.0
214+
name: virtualenv==20.28.0
217215
executable: /var/www/extuser/yoda-external-user-service/venv/bin/pip3
218216

219217

@@ -225,6 +223,16 @@
225223
creates: "/var/www/extuser/yoda-external-user-service/venv/bin/activate_this.py"
226224

227225

226+
# Upgrade pip after seeding, because virtualenv installs its own bundled pip version.
227+
- name: Upgrade pip in Yoda EUS virtual environment
228+
become_user: '{{ yoda_deployment_user }}'
229+
become: true
230+
ansible.builtin.pip:
231+
requirements: "{{ python3_venv_pip_requirements }}"
232+
extra_args: --require-hashes
233+
executable: /var/www/extuser/yoda-external-user-service/venv/bin/pip3
234+
235+
228236
# Change detection in git repositories is unreliable in some Ansible versions, so we always
229237
# run this task, just to be sure.
230238
- name: Ensure Yoda EUS dependencies are installed

‎roles/yoda_moai/tasks/main.yml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,20 @@
5555
creates: "{{ yoda_moai_home }}/yoda-moai/venv/bin/activate_this.py"
5656

5757

58-
- name: Upgrade pip and virtualenv in Yoda MOAI environment
58+
- name: Upgrade pip in Yoda MOAI environment
5959
become_user: '{{ yoda_moai_user }}'
6060
become: true
6161
ansible.builtin.pip:
62-
name:
63-
- pip==26.0.1
64-
- virtualenv==20.28.0
62+
requirements: "{{ python3_venv_pip_requirements }}"
63+
extra_args: --require-hashes
64+
executable: /var/www/moai/yoda-moai/venv/bin/pip3
65+
66+
67+
- name: Ensure virtualenv is installed in Yoda MOAI environment
68+
become_user: '{{ yoda_moai_user }}'
69+
become: true
70+
ansible.builtin.pip:
71+
name: virtualenv==20.28.0
6572
executable: /var/www/moai/yoda-moai/venv/bin/pip3
6673

6774

‎roles/yoda_portal/tasks/main.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
become_user: "{{ yoda_deployment_user }}"
8282
become: true
8383
ansible.builtin.pip:
84-
name:
85-
- pip==25.0
84+
requirements: "{{ python3_venv_pip_requirements }}"
85+
extra_args: --require-hashes
8686
executable: /var/www/yoda/venv/bin/pip3.12
8787

8888

0 commit comments

Comments
 (0)