Skip to content

Commit 0ffa544

Browse files
Merge branch 'main' into universal_unpin_dotnet_rntime_core_versions
2 parents bdf8db3 + 018b799 commit 0ffa544

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

src/anaconda/.devcontainer/apply_security_patches.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
vulnerable_packages=( "pydantic=2.5.3" "joblib=1.3.1" "mistune=3.0.1" "werkzeug=3.0.3" "transformers=4.36.0" "pillow=10.3.0" "aiohttp=3.9.4" \
4-
"cryptography=42.0.4" "gitpython=3.1.41" "jupyter-lsp=2.2.2" "idna=3.7" "jinja2=3.1.4" "scrapy=2.11.2" )
4+
"cryptography=42.0.4" "gitpython=3.1.41" "jupyter-lsp=2.2.2" "idna=3.7" "jinja2=3.1.4" "scrapy=2.11.2" "black=24.4.2")
55

66
# Define the number of rows (based on the length of vulnerable_packages)
77
rows=${#vulnerable_packages[@]}
@@ -30,7 +30,7 @@ for ((i=0; i<rows; i++)); do
3030
echo "${packages_array[$i,0]} version v${CURRENT_VERSION} installed by the base image is not greater or equal to the required: v${REQUIRED_VERSION}"
3131
# Check whether conda channel has a greater or equal version available, so install from conda, otherwise use pip package manager
3232
channel_name="anaconda"
33-
CONDA_VERSION=$(conda search --override-channels "${packages_array[$i,0]}" -c "$channel_name" | \
33+
CONDA_VERSION=$(conda search "${packages_array[$i,0]}" -c "$channel_name" | \
3434
grep -E '^[[:alnum:]]' | \
3535
awk '{print $2}' | \
3636
sort -V | \

src/anaconda/test-project/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ checkCondaPackageVersion "mpmath" "1.3.0"
6262
checkCondaPackageVersion "urllib3" "1.26.17"
6363
checkCondaPackageVersion "pyarrow" "14.0.1"
6464
checkCondaPackageVersion "pydantic" "2.5.3"
65+
checkCondaPackageVersion "black" "24.4.2"
6566

6667
check "conda-update-conda" bash -c "conda update -y conda"
6768
check "conda-install-tensorflow" bash -c "conda create --name test-env -c conda-forge --yes tensorflow"

src/miniconda/.devcontainer/Dockerfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
FROM continuumio/miniconda3 as upstream
22

3-
# Temporary: Upgrade python packages due to mentioned CVEs
4-
# They are installed by the base image (continuumio/miniconda3) which does not have the patch.
5-
RUN conda install \
6-
# https://github.com/advisories/GHSA-jjg7-2v4v-x38h
7-
idna==3.7
8-
9-
# Temporary: Upgrade python packages using pip package manager
10-
# RUN python3 -m pip install --upgrade \
11-
# https://github.com/advisories/
12-
# package==version
3+
# Temporary: Upgrade python packages
4+
COPY ./apply_security_patches.sh /tmp/apply_security_patches.sh
5+
RUN chmod +x /tmp/apply_security_patches.sh
6+
RUN /tmp/apply_security_patches.sh
137

148
# Reset and copy updated files with updated privs to keep image size down
159
FROM mcr.microsoft.com/devcontainers/base:1-bullseye
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# define array of packages for pinning to the patched versions
4+
# vulnerable_packages=( "package1=version1" "package2=version2" "package3=version3" )
5+
vulnerable_packages=( "tqdm=4.66.4" )
6+
7+
# Define the number of rows (based on the length of vulnerable_packages)
8+
rows=${#vulnerable_packages[@]}
9+
10+
# Define the number of columns
11+
cols=2
12+
13+
# Define the 2D array
14+
declare -A packages_array
15+
16+
# Fill the 2D array
17+
for ((i=0; i<rows; i++)); do
18+
# Split each element of vulnerable_packages by the '=' sign
19+
IFS='=' read -ra parts <<< "${vulnerable_packages[$i]}"
20+
# Assign the parts to the 2D array
21+
packages_array[$i,0]=${parts[0]}
22+
packages_array[$i,1]=${parts[1]}
23+
done
24+
25+
for ((i=0; i<rows; i++)); do
26+
CURRENT_VERSION=$(pip show "${packages_array[$i,0]}" --disable-pip-version-check | grep '^Version:' | awk '{print $2}')
27+
REQUIRED_VERSION="${packages_array[$i,1]}"
28+
GREATER_VERSION_A=$((echo ${REQUIRED_VERSION}; echo ${CURRENT_VERSION}) | sort -V | tail -1)
29+
# Check if the required_version is greater than current_version
30+
if [[ $CURRENT_VERSION != $GREATER_VERSION_A ]]; then
31+
echo "${packages_array[$i,0]} version v${CURRENT_VERSION} installed by the base image is not greater or equal to the required: v${REQUIRED_VERSION}"
32+
# Check whether conda channel has a greater or equal version available, so install from conda, otherwise use pip package manager
33+
channel_name="anaconda"
34+
CONDA_VERSION=$(conda search "${packages_array[$i,0]}" -c "$channel_name" | \
35+
grep -E '^[[:alnum:]]' | \
36+
awk '{print $2}' | \
37+
sort -V | \
38+
uniq | \
39+
tail -n 2 | \
40+
head -n 1)
41+
if [[ -z "$CONDA_VERSION" ]]; then
42+
echo "No version for ${packages_array[$i,0]} found in conda channel."
43+
CONDA_VERSION="0"
44+
fi
45+
GREATER_VERSION_B=$((echo ${REQUIRED_VERSION}; echo ${CONDA_VERSION}) | sort -V | tail -1)
46+
if [[ $CONDA_VERSION == $GREATER_VERSION_B ]]; then
47+
echo -e "Found Version v${CONDA_VERSION} in the Conda channel which is greater than or equal to the required version: v${REQUIRED_VERSION}. \n";
48+
echo "Installing ${packages_array[$i,0]} from source from conda channel for v${REQUIRED_VERSION}..."
49+
conda install "${packages_array[$i,0]}==${CONDA_VERSION}"
50+
elif [[ $REQUIRED_VERSION == $GREATER_VERSION_B ]]; then
51+
echo -e "Required version: v${REQUIRED_VERSION} is greater than the version found in the Conda channel v${CONDA_VERSION}. \n";
52+
echo "Installing ${packages_array[$i,0]} from source from pip package manager for v${REQUIRED_VERSION}..."
53+
python3 -m pip install --upgrade --no-cache-dir "${packages_array[$i,0]}==${REQUIRED_VERSION}"
54+
fi
55+
fi
56+
done

src/miniconda/test-project/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ checkCondaPackageVersion "wheel" "0.38.1"
2828
checkCondaPackageVersion "requests" "2.31.0"
2929
checkCondaPackageVersion "urllib3" "1.26.17"
3030
checkCondaPackageVersion "idna" "3.7"
31+
checkCondaPackageVersion "tqdm" "4.66.4"
3132

3233
check "conda-update-conda" bash -c "conda update -y conda"
3334
check "conda-install-tensorflow" bash -c "conda create --name test-env -c conda-forge --yes tensorflow"

0 commit comments

Comments
 (0)