Skip to content

Commit 179197e

Browse files
Universal Anaconda Python: Update "setuptools" due to CVE-2022-40897 (devcontainers#455)
* Universal Anaconda Python: Update "setuptools" due to CVE-2022-40897 * patch anaconda * update test * update test * update how we update setuptools
1 parent 465647d commit 179197e

File tree

9 files changed

+34
-0
lines changed

9 files changed

+34
-0
lines changed

src/anaconda/.devcontainer/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ RUN python3 -m pip install \
6666
numpy \
6767
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-23491
6868
certifi \
69+
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
70+
setuptools \
6971
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40899
7072
future \
7173
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40898

src/anaconda/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"mistune",
3131
"numpy",
3232
"certifi",
33+
"setuptools",
3334
"future",
3435
"wheel"
3536
],

src/anaconda/test-project/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ check-version-ge "mistune-requirement" "${mistune_version}" "2.0.3"
4444
numpy_version=$(python -c "import numpy; print(numpy.__version__)")
4545
check-version-ge "numpy-requirement" "${numpy_version}" "1.22"
4646

47+
setuptools_version=$(python -c "import setuptools; print(setuptools.__version__)")
48+
check-version-ge "setuptools-requirement" "${setuptools_version}" "65.5.1"
49+
4750
future_version=$(python -c "import future; print(future.__version__)")
4851
check-version-ge "future-requirement" "${future_version}" "0.18.3"
4952

src/python/.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
66
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
77
&& apt-get purge -y imagemagick imagemagick-6-common
88

9+
# Temporary: Upgrade python packages due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
10+
# They are installed by the base image (python) which does not have the patch.
11+
RUN python3 -m pip install --upgrade setuptools
12+
913
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
1014
# COPY requirements.txt /tmp/pip-tmp/
1115
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \

src/python/manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
"virtualenv",
107107
"pipx"
108108
],
109+
"pip": [
110+
"setuptools"
111+
],
109112
"languages": {
110113
"Python": {
111114
"cgIgnore": true,

src/python/test-project/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ check "gitconfig-contains-name" sh -c "cat /etc/gitconfig | grep 'name = devcont
3939

4040
check "usr-local-etc-config-does-not-exist" test ! -f "/usr/local/etc/gitconfig"
4141

42+
setuptools_version=$(python -c "import setuptools; print(setuptools.__version__)")
43+
check-version-ge "setuptools-requirement" "${setuptools_version}" "65.5.1"
44+
4245
# Report result
4346
reportResults

src/universal/.devcontainer/local-features/setup-user/install.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ rm -rf /usr/local/nvs/deps/node_modules/follow-redirects/*
3939
curl -sSL https://github.com/follow-redirects/follow-redirects/archive/refs/tags/v1.15.2.tar.gz | tar -xzC /tmp 2>&1
4040
mv /tmp/follow-redirects-1.15.2/* /usr/local/nvs/deps/node_modules/follow-redirects/
4141

42+
sudo_if() {
43+
COMMAND="$*"
44+
if [ "$(id -u)" -eq 0 ] && [ "$USERNAME" != "root" ]; then
45+
su - "$USERNAME" -c "$COMMAND"
46+
else
47+
"$COMMAND"
48+
fi
49+
}
50+
51+
# Temporary: Upgrade python packages due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
52+
# They are installed by the base image (python) which does not have the patch.
53+
sudo_if /usr/local/python/current/bin/python -m pip uninstall --yes setuptools
54+
sudo_if /usr/local/python/current/bin/python -m pip install --user --upgrade --no-cache-dir setuptools
55+
4256
# Enables the oryx tool to generate manifest-dir which is needed for running the postcreate tool
4357
DEBIAN_FLAVOR="focal-scm"
4458
mkdir -p /opt/oryx && echo "vso-focal" > /opt/oryx/.imagetype

src/universal/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"plotly",
120120
"jupyterlab-git",
121121
"certifi",
122+
"setuptools",
122123
"wheel"
123124
],
124125
"other": {

src/universal/test-project/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ check "torch" python -c "import torch; print(torch.__version__)"
5555
check "requests" python -c "import requests; print(requests.__version__)"
5656
check "jupyterlab-git" bash -c "python3 -m pip list | grep jupyterlab-git"
5757

58+
setuptools_version=$(python3 -c "import setuptools; print(setuptools.__version__)")
59+
check-version-ge "setuptools-requirement" "${setuptools_version}" "65.5.1"
60+
5861
# Check JupyterLab
5962
check "jupyter-lab" jupyter-lab --version
6063
check "jupyter-lab config" grep ".*.allow_origin = '*'" /home/codespace/.jupyter/jupyter_server_config.py

0 commit comments

Comments
 (0)