Skip to content

Commit bc0a54f

Browse files
committed
[GHA] fix the regexp used for the latest image tag selection
In case that there is an image tag subpart of another tag, there could be wrong tag chosen and as a result wrong SHA used for the manifest update. E.g. these two: * "rstudio-c9s-python-3.9-2024a-20240315-02193dd", * "cuda-rstudio-c9s-python-3.9-2024a-20240315-02193dd", Example of wrong update #541 (3df148c). Together with this, I also updated the quay security analysis script where is the exact same issue.
1 parent 8461fce commit bc0a54f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

.github/workflows/notebooks-digest-updater-upstream.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2)
8585
registry=$(echo $img | cut -d '@' -f1)
8686
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
87-
regex="$src_tag-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}"
87+
regex="^$src_tag-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}\$"
8888
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
8989
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
9090
output=$registry@$digest
@@ -164,7 +164,7 @@ jobs:
164164
img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2)
165165
registry=$(echo $img | cut -d '@' -f1)
166166
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
167-
regex="$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}"
167+
regex="^$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}\$"
168168
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
169169
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
170170
output=$registry@$digest

.github/workflows/runtimes-digest-updater-upstream.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
name="minimal-$name"
9393
fi
9494
registry=$(echo $img | cut -d '@' -f1)
95-
regex="runtime-$name-$py_version-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}"
95+
regex="^runtime-$name-$py_version-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}\$"
9696
echo "CHECKING: " $regex
9797
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
9898
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')

ci/security-scan/quay_security_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def process_image(image, commit_id_path, RELEASE_VERSION_N, HASH_N):
8181
regex = ""
8282

8383
if RELEASE_VERSION_N == "":
84-
regex = f"{src_tag}-(\\d+-)?{HASH_N}"
84+
regex = f"^{src_tag}-(\\d+-)?{HASH_N}$"
8585
else:
86-
regex = f"{src_tag}-{RELEASE_VERSION_N}-\\d+-{HASH_N}"
86+
regex = f"^{src_tag}-{RELEASE_VERSION_N}-\\d+-{HASH_N}$"
8787

8888
latest_tag_cmd = f'skopeo inspect docker://{img} | jq -r --arg regex "{regex}" \'.RepoTags | map(select(. | test($regex))) | .[0]\''
8989
latest_tag = subprocess.check_output(latest_tag_cmd, shell=True, text=True).strip()

0 commit comments

Comments
 (0)