Skip to content

Commit

Permalink
[universal] Bump Python SDK versions (#831)
Browse files Browse the repository at this point in the history
* Bump Python SDKs versions

- v3.10: 3.10.8 -> 3.10.13
- v3.9: 3.9.16 -> 3.9.18

* [patch-conda] Remove outdated patches

* [patch-python] Remove outdated patches

* [patch-python/patch-conda] Add `pip show` command

* [test-utils] Update `checkPythonPackageVersion` function to make it generic

* [patch-python] Rework `update_package` feature
  • Loading branch information
alexander-smolyakov authored Nov 6, 2023
1 parent 0ce3c38 commit a9e71e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/universal/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"./local-features/nvs": "latest",
"ghcr.io/devcontainers/features/python:1": {
"version": "3.10.8",
"additionalVersions": "3.9.16",
"version": "3.10.13",
"additionalVersions": "3.9.18",
"installJupyterlab": "true",
"configureJupyterlabAllowOrigin": "*",
"useOryxIfAvailable": "false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ update_python_package() {

sudo_if "$PYTHON_PATH -m pip uninstall --yes $PACKAGE"
sudo_if "$PYTHON_PATH -m pip install --upgrade --no-cache-dir $PACKAGE==$VERSION"
sudo_if "$PYTHON_PATH -m pip show --no-python-version-warning $PACKAGE"
}

update_conda_package() {
Expand All @@ -50,14 +51,8 @@ sudo_if /opt/conda/bin/python3 -m pip install --upgrade pip
# Temporary: Upgrade python packages due to security vulnerabilities
# They are installed by the conda feature and Conda distribution does not have the patches.

# pyopenssl should be updated to be compatible with latest version of cryptography
update_conda_package pyopenssl "23.2.0"

# https://github.com/advisories/GHSA-v8gr-m533-ghj9
update_python_package /opt/conda/bin/python3 cryptography "41.0.4"

# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-32681
update_conda_package requests "2.31.0"

# https://github.com/advisories/GHSA-v845-jxx5-vc9f
update_conda_package urllib3 "1.26.18"
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ sudo_if() {
update_package() {
PYTHON_PATH=$1
PACKAGE=$2
VERSION=$3

sudo_if "$PYTHON_PATH -m pip uninstall --yes $PACKAGE"
sudo_if "$PYTHON_PATH -m pip install --upgrade --no-cache-dir $PACKAGE"
sudo_if "$PYTHON_PATH -m pip install --upgrade --no-cache-dir $PACKAGE==$VERSION"
sudo_if "$PYTHON_PATH -m pip show --no-python-version-warning $PACKAGE"
}

# Temporary: Upgrade python packages due to security vulnerabilities
# They are installed by the base image (python) which does not have the patch.

# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
update_package /usr/local/python/3.9.*/bin/python setuptools==65.5.1
update_package /usr/local/python/3.10.*/bin/python setuptools==68.0.0

# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-32681
update_package /usr/local/python/3.10.*/bin/python requests==2.31.0
update_package /usr/local/python/3.9.*/bin/python setuptools 65.5.1
2 changes: 1 addition & 1 deletion src/universal/test-project/test-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ checkPythonPackageVersion()
PACKAGE=$2
REQUIRED_VERSION=$3

current_version=$(${PYTHON_PATH} -c "import ${PACKAGE}; print(${PACKAGE}.__version__)")
current_version=$(${PYTHON_PATH} -c "import importlib.metadata; print(importlib.metadata.version('${PACKAGE}'))")
check-version-ge "${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
}

Expand Down

0 comments on commit a9e71e6

Please sign in to comment.