Skip to content

Commit 3dc5502

Browse files
authored
[anaconda] - Fix to stick to transformers version 4.49.0 (#1428)
1 parent 1d4c207 commit 3dc5502

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/anaconda/.devcontainer/apply_security_patches.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# vulnerabilities:
44
# werkzeug - [GHSA-f9vj-2wh5-fj8j]
55

6-
vulnerable_packages=( "mistune=3.0.1" "transformers=4.36.0" "cryptography=43.0.3" "jupyter-lsp=2.2.2" "scrapy=2.11.2" \
6+
vulnerable_packages=( "mistune=3.0.1" "transformers=4.49.0" "cryptography=43.0.3" "jupyter-lsp=2.2.2" "scrapy=2.11.2" \
77
"zipp=3.19.1" "tornado=6.4.2")
88

99
# Define the number of rows (based on the length of vulnerable_packages)
@@ -24,6 +24,21 @@ for ((i=0; i<rows; i++)); do
2424
packages_array[$i,1]=${parts[1]}
2525
done
2626

27+
# Add an array for packages that should always pin to the provided version,
28+
# even if higher version is available in conda channel
29+
pin_to_required_version=( "transformers" "cryptography" ) # Add package names as needed
30+
31+
# Function to check if a package is in the pin_to_required_version array
32+
function is_pin_to_required_version() {
33+
local pkg="$1"
34+
for item in "${pin_to_required_version[@]}"; do
35+
if [[ "$item" == "$pkg" ]]; then
36+
return 0
37+
fi
38+
done
39+
return 1
40+
}
41+
2742
for ((i=0; i<rows; i++)); do
2843
CURRENT_VERSION=$(pip show "${packages_array[$i,0]}" --disable-pip-version-check | grep '^Version:' | awk '{print $2}')
2944
REQUIRED_VERSION="${packages_array[$i,1]}"
@@ -45,12 +60,16 @@ for ((i=0; i<rows; i++)); do
4560
CONDA_VERSION="0"
4661
fi
4762
GREATER_VERSION_B=$((echo ${REQUIRED_VERSION}; echo ${CONDA_VERSION}) | sort -V | tail -1)
48-
if [[ $CONDA_VERSION == $GREATER_VERSION_B && ${packages_array[$i,0]} != "cryptography" ]]; then
63+
if is_pin_to_required_version "${packages_array[$i,0]}"; then
64+
echo -e "Package ${packages_array[$i,0]} is set to always use the required version: v${REQUIRED_VERSION}.\n";
65+
echo "Installing ${packages_array[$i,0]} from pip for v${REQUIRED_VERSION}..."
66+
python3 -m pip install --upgrade --no-cache-dir "${packages_array[$i,0]}==${REQUIRED_VERSION}"
67+
elif [[ $CONDA_VERSION == $GREATER_VERSION_B ]]; then
4968
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";
5069
echo "Installing ${packages_array[$i,0]} from source from conda channel for v${REQUIRED_VERSION}..."
5170
conda install "${packages_array[$i,0]}==${CONDA_VERSION}"
52-
elif [[ $REQUIRED_VERSION == $GREATER_VERSION_B || ${packages_array[$i,0]} == "cryptography" ]]; then
53-
echo -e "Required version: v${REQUIRED_VERSION} is greater than the version found in the Conda channel v${CONDA_VERSION} or its cryptography package. \n";
71+
elif [[ $REQUIRED_VERSION == $GREATER_VERSION_B ]]; then
72+
echo -e "Required version: v${REQUIRED_VERSION} is greater than the version found in the Conda channel v${CONDA_VERSION}. \n";
5473
echo "Installing ${packages_array[$i,0]} from source from pip package manager for v${REQUIRED_VERSION}..."
5574
python3 -m pip install --upgrade --no-cache-dir "${packages_array[$i,0]}==${REQUIRED_VERSION}"
5675
fi

src/anaconda/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.2.3",
2+
"version": "1.2.4",
33
"build": {
44
"latest": true,
55
"rootDistro": "debian",

0 commit comments

Comments
 (0)