Skip to content

Commit 4913fb2

Browse files
[miniconda] Patch Python due to GHSA-5cpq-8wj7-hf2v (devcontainers#634)
* [miniconda] Patch Python due to GHSA-5cpq-8wj7-hf2v - Update Dockerfile to install the latest versions of pyopenssl and cryptography; - Added tests to verify minimum version for pyopenssl and cryptography packages; - Added tests to verify minimum package version via `conda list` command. * Fix text * Rework fix * test: Replace command * test: Enable `pip_interop_enabled` for conda * Rework patch * Fix dockerfile * Test: Restore patch for `requests` package * Update test.sh * Update Dockerfile * Revert patch for `requests` package due to issues with `conda-install` test
1 parent 99acaad commit 4913fb2

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/miniconda/.devcontainer/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bi
4141

4242
# Temporary: Upgrade python packages due to mentioned CVEs
4343
# They are installed by the base image (continuumio/miniconda3) which does not have the patch.
44-
RUN python3 -m pip install --upgrade \
45-
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-32681
46-
requests
44+
RUN conda install \
45+
# https://github.com/pyca/cryptography/security/advisories/GHSA-5cpq-8wj7-hf2v
46+
pyopenssl=23.2.0 \
47+
cryptography=41.0.2
4748

4849
# [Optional] Uncomment this section to install additional OS packages.
4950
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

src/miniconda/test-project/test-utils.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,11 @@ checkPythonPackageVersion()
172172
current_version=$(python -c "import ${PACKAGE}; print(${PACKAGE}.__version__)")
173173
check-version-ge "${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
174174
}
175+
176+
checkCondaPackageVersion()
177+
{
178+
PACKAGE=$1
179+
REQUIRED_VERSION=$2
180+
current_version=$(conda list "${PACKAGE}" | grep -w "${PACKAGE}" | awk '{print $2}')
181+
check-version-ge "conda-${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
182+
}

src/miniconda/test-project/test.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ check "gitconfig-contains-name" sh -c "cat /etc/gitconfig | grep 'name = devcont
1818

1919
check "usr-local-etc-config-does-not-exist" test ! -f "/usr/local/etc/gitconfig"
2020

21-
checkPythonPackageVersion "cryptography" "38.0.3"
21+
checkPythonPackageVersion "cryptography" "41.0.0"
2222
checkPythonPackageVersion "setuptools" "65.5.1"
2323
checkPythonPackageVersion "wheel" "0.38.1"
24-
checkPythonPackageVersion "requests" "2.31.0"
24+
25+
checkCondaPackageVersion "cryptography" "41.0.0"
26+
checkCondaPackageVersion "pyopenssl" "23.2.0"
27+
checkCondaPackageVersion "setuptools" "65.5.1"
28+
checkCondaPackageVersion "wheel" "0.38.1"
2529

2630
check "conda-update-conda" bash -c "conda update -y conda"
27-
check "conda-install" bash -c "conda install -c conda-forge --yes tensorflow"
28-
check "conda-install" bash -c "conda install -c conda-forge --yes pytorch"
31+
check "conda-install-tensorflow" bash -c "conda install -c conda-forge --yes tensorflow"
32+
check "conda-install-pytorch" bash -c "conda install -c conda-forge --yes pytorch"
2933

3034
# Report result
3135
reportResults

0 commit comments

Comments
 (0)