Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7092061
[universal] Conda: patch Python due to CVE-2023-32681 and GHSA-5cpq-8…
alexander-smolyakov Jun 15, 2023
d7d8505
Merge remote-tracking branch 'upstream/main' into users/alexander-smo…
alexander-smolyakov Jun 16, 2023
046b94c
Review comment: Update features schema and container schema
alexander-smolyakov Jun 16, 2023
408276c
Restart checks
alexander-smolyakov Jun 16, 2023
e83a600
Revert "Review comment: Update features schema and container schema"
alexander-smolyakov Jun 16, 2023
97ed40c
Review comment: Update features schema and container schema
alexander-smolyakov Jun 16, 2023
e27d89f
Review comment: Add tests
alexander-smolyakov Jun 16, 2023
ca95a03
Set up `installsAfter` for features
alexander-smolyakov Jun 19, 2023
aaa2335
Merge remote-tracking branch 'upstream/main' into users/alexander-smo…
alexander-smolyakov Jun 21, 2023
f172ea6
Define `installsAfter` for `patch-conda` feature
alexander-smolyakov Jun 21, 2023
c553c4e
Lock packages version
alexander-smolyakov Jun 21, 2023
f8b1def
Add tests for conda
alexander-smolyakov Jun 21, 2023
0244358
Merge remote-tracking branch 'upstream/main' into users/alexander-smo…
alexander-smolyakov Jul 26, 2023
f39b4ea
Merge remote-tracking branch 'upstream/main' into users/alexander-smo…
alexander-smolyakov Jul 27, 2023
abd03d2
Rework patch
alexander-smolyakov Jul 27, 2023
64e3a73
Bump `cryptography` version
alexander-smolyakov Jul 27, 2023
69aa190
Bump `cryptography` version
alexander-smolyakov Jul 27, 2023
da0e49e
Restart checks
alexander-smolyakov Jul 27, 2023
a74d406
Add tests
alexander-smolyakov Jul 27, 2023
0c1b4ae
Revert "Add tests"
alexander-smolyakov Jul 27, 2023
066fd4b
Update test-utils.sh
alexander-smolyakov Jul 27, 2023
575c860
Restart checks
alexander-smolyakov Jul 28, 2023
0da3381
Merge branch 'main' into users/alexander-smolyakov/universal_GHSA-5cp…
alexander-smolyakov Jul 28, 2023
d486e30
Merge branch 'main' into users/alexander-smolyakov/universal_GHSA-5cp…
alexander-smolyakov Jul 31, 2023
396913a
Restart checks
alexander-smolyakov Jul 31, 2023
46d6d34
Merge branch 'main' into users/alexander-smolyakov/universal_GHSA-5cp…
alexander-smolyakov Aug 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/universal/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"./local-features/jekyll": "latest",
"ghcr.io/devcontainers/features/oryx:1": "latest",
"./local-features/setup-user": "latest",
"./local-features/patch-python": "latest"
"./local-features/patch-python": {},
"./local-features/patch-conda": {}
},
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils",
Expand All @@ -81,11 +82,12 @@
"ghcr.io/devcontainers/features/hugo",
"ghcr.io/devcontainers/features/node",
"./local-features/nvs",
"ghcr.io/devcontainers/features/conda",
"./local-features/patch-conda",
"ghcr.io/devcontainers/features/python",
"./local-features/patch-python",
"./local-features/machine-learning-packages",
"ghcr.io/devcontainers/features/php",
"ghcr.io/devcontainers/features/conda",
"ghcr.io/devcontainers/features/ruby",
"ghcr.io/devcontainers/features/java",
"ghcr.io/devcontainers/features/sshd",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"installsAfter": [
"ghcr.io/devcontainers/features/python"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "patch-conda",
"name": "Patch Conda Packages",
"installsAfter": [
"ghcr.io/devcontainers/features/conda"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

USERNAME=${USERNAME:-"codespace"}

set -eux

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh

export DEBIAN_FRONTEND=noninteractive

sudo_if() {
COMMAND="$*"
if [ "$(id -u)" -eq 0 ] && [ "$USERNAME" != "root" ]; then
su - "$USERNAME" -c "$COMMAND"
else
"$COMMAND"
fi
}

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==$VERSION"
}

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.

# https://github.com/advisories/GHSA-5cpq-8wj7-hf2v
update_package /opt/conda/bin/python3 pyopenssl "23.2.0"
update_package /opt/conda/bin/python3 cryptography "41.0.0"

# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-32681
update_package /opt/conda/bin/python3 requests "2.31.0"
18 changes: 18 additions & 0 deletions src/universal/test-project/test-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,21 @@ checkDirectoryOwnership() {
return 1
fi
}

checkPythonPackageVersion()
{
PYTHON_PATH=$1
PACKAGE=$2
REQUIRED_VERSION=$3

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

checkCondaPackageVersion()
{
PACKAGE=$1
REQUIRED_VERSION=$2
current_version=$(conda list "${PACKAGE}" | grep -w "${PACKAGE}" | awk '{print $2}')
check-version-ge "conda-${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
}
21 changes: 11 additions & 10 deletions src/universal/test-project/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ check "torch" python -c "import torch; print(torch.__version__)"
check "requests" python -c "import requests; print(requests.__version__)"
check "jupyterlab-git" bash -c "python3 -m pip list | grep jupyterlab-git"

setuptools_version=$(python3 -c "import setuptools; print(setuptools.__version__)")
check-version-ge "setuptools-requirement" "${setuptools_version}" "65.5.1"

# Check JupyterLab
check "jupyter-lab" jupyter-lab --version
check "jupyter-lab config" grep ".*.allow_origin = '*'" /home/codespace/.jupyter/jupyter_server_config.py
Expand Down Expand Up @@ -187,16 +184,20 @@ check "java-version-on-path-is-12.0.2" java --version | grep 12.0.2
MAVEN_PATH=$(cd /usr/local/sdkman/candidates/maven/3*/lib/ && pwd)
check "commons-io-lib" bash -c "ls ${MAVEN_PATH} | grep commons-io-2.11.jar"

wheel_version=$(python -c "import wheel; print(wheel.__version__)")
check-version-ge "wheel-requirement" "${wheel_version}" "0.38.1"

ls -la /home/codespace

setuptools_version_py_current=$(python -c "import setuptools; print(setuptools.__version__)")
check-version-ge "setuptools-requirement-python_current" "${setuptools_version_py_current}" "65.5.1"
## Python - current
checkPythonPackageVersion "python" "wheel" "0.38.1"
checkPythonPackageVersion "python" "setuptools" "65.5.1"
checkPythonPackageVersion "python" "requests" "2.31.0"

## Python 3.9
checkPythonPackageVersion "/usr/local/python/3.9.*/bin/python" "setuptools" "65.5.1"

setuptools_version_py_39=$(/usr/local/python/3.9.*/bin/python -c "import setuptools; print(setuptools.__version__)")
check-version-ge "setuptools-requirement-python_39" "${setuptools_version_py_39}" "65.5.1"
## Conda Python
checkCondaPackageVersion "requests" "2.31.0"
checkCondaPackageVersion "cryptography" "41.0.0"
checkCondaPackageVersion "pyopenssl" "23.2.0"

# Report result
reportResults