Skip to content

Commit 4088e28

Browse files
CopilotKaniska244
andcommitted
Quote associative array subscripts
Co-authored-by: Kaniska244 <186041440+Kaniska244@users.noreply.github.com>
1 parent cdf7723 commit 4088e28

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/anaconda/.devcontainer/apply_security_patches.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ for ((i=0; i<rows; i++)); do
2121
# Split each element of vulnerable_packages by the '=' sign
2222
IFS='=' read -ra parts <<< "${vulnerable_packages[$i]}"
2323
# Assign the parts to the 2D array
24-
packages_array[$i,0]=${parts[0]}
25-
packages_array[$i,1]=${parts[1]}
26-
required_versions[${parts[0]}]=${parts[1]}
24+
packages_array["$i,0"]="${parts[0]}"
25+
packages_array["$i,1"]="${parts[1]}"
26+
required_versions["${parts[0]}"]="${parts[1]}"
2727
done
2828

2929
# Add an array for packages that should always pin to the provided version,
@@ -42,44 +42,44 @@ function is_pin_to_required_version() {
4242
}
4343

4444
for ((i=0; i<rows; i++)); do
45-
CURRENT_VERSION=$(pip show "${packages_array[$i,0]}" --disable-pip-version-check | grep '^Version:' | awk '{print $2}')
46-
REQUIRED_VERSION="${packages_array[$i,1]}"
47-
if is_pin_to_required_version "${packages_array[$i,0]}"; then
45+
CURRENT_VERSION=$(pip show "${packages_array["$i,0"]}" --disable-pip-version-check | grep '^Version:' | awk '{print $2}')
46+
REQUIRED_VERSION="${packages_array["$i,1"]}"
47+
if is_pin_to_required_version "${packages_array["$i,0"]}"; then
4848
continue
4949
fi
5050
GREATER_VERSION_A=$( (echo ${REQUIRED_VERSION}; echo ${CURRENT_VERSION}) | sort -V | tail -1)
5151
# Check if the required_version is greater than current_version
5252
if [[ $CURRENT_VERSION != $GREATER_VERSION_A ]]; then
53-
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}"
53+
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}"
5454
# Check whether conda channel has a greater or equal version available, so install from conda, otherwise use pip package manager
5555
channel_name="anaconda"
56-
CONDA_VERSION=$(conda search "${packages_array[$i,0]}" -c "$channel_name" | \
56+
CONDA_VERSION=$(conda search "${packages_array["$i,0"]}" -c "$channel_name" | \
5757
grep -E '^[[:alnum:]]' | \
5858
awk '{print $2}' | \
5959
sort -V | \
6060
uniq | \
6161
tail -n 2 | \
6262
head -n 1)
6363
if [[ -z "$CONDA_VERSION" ]]; then
64-
echo "No version for ${packages_array[$i,0]} found in conda channel."
64+
echo "No version for ${packages_array["$i,0"]} found in conda channel."
6565
CONDA_VERSION="0"
6666
fi
6767
GREATER_VERSION_B=$( (echo ${REQUIRED_VERSION}; echo ${CONDA_VERSION}) | sort -V | tail -1)
6868
if [[ $CONDA_VERSION == $GREATER_VERSION_B ]]; then
6969
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";
70-
echo "Installing ${packages_array[$i,0]} from source from conda channel for v${REQUIRED_VERSION}..."
71-
conda install "${packages_array[$i,0]}==${CONDA_VERSION}"
70+
echo "Installing ${packages_array["$i,0"]} from source from conda channel for v${REQUIRED_VERSION}..."
71+
conda install "${packages_array["$i,0"]}==${CONDA_VERSION}"
7272
elif [[ $REQUIRED_VERSION == $GREATER_VERSION_B ]]; then
7373
echo -e "Required version: v${REQUIRED_VERSION} is greater than the version found in the Conda channel v${CONDA_VERSION}. \n";
74-
echo "Installing ${packages_array[$i,0]} from source from pip package manager for v${REQUIRED_VERSION}..."
75-
python3 -m pip install --upgrade --no-cache-dir "${packages_array[$i,0]}==${REQUIRED_VERSION}"
74+
echo "Installing ${packages_array["$i,0"]} from source from pip package manager for v${REQUIRED_VERSION}..."
75+
python3 -m pip install --upgrade --no-cache-dir "${packages_array["$i,0"]}==${REQUIRED_VERSION}"
7676
fi
7777
fi
7878
done
7979

8080
# After the main upgrade loop, install packages from the pin_to_required_version list at their required versions to keep exact versions even if conda upgrades them as dependencies.
8181
for pkg in "${pin_to_required_version[@]}"; do
82-
REQUIRED_VERSION="${required_versions[$pkg]}"
82+
REQUIRED_VERSION="${required_versions["$pkg"]}"
8383
if [[ -z "${REQUIRED_VERSION}" ]]; then
8484
echo "WARNING: Missing required version for ${pkg}. Skipping installation."
8585
continue

0 commit comments

Comments
 (0)