Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7171d52

Browse files
authored
fix: replace both colons and slashes in SBOM filename for Docker image (#16915)
This PR fixes the SBOM filename generation in the Docker build script to properly handle image tags that contain slashes. The current implementation only replaces colons with underscores, but fails when image tags include slashes (common in registry paths). The fix updates the string replacement to handle both colons and slashes in the image tag when generating the SBOM filename. Change-Id: Ifd7bad6d165393e11202e5bf070a4cb26eaa6a6a Signed-off-by: Thomas Kosiewski <[email protected]> Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 389af22 commit 7171d52

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/build_docker.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ if [[ "$push" == 1 ]]; then
154154
fi
155155

156156
log "--- Generating SBOM for Docker image ($image_tag)"
157-
syft "$image_tag" -o spdx-json >"${image_tag//:/_}.spdx.json"
157+
syft "$image_tag" -o spdx-json >"${image_tag//[:\/]/_}.spdx.json"
158158

159159
if [[ "$push" == 1 ]]; then
160160
log "--- Attesting SBOM to Docker image for $arch ($image_tag)"
161161
COSIGN_EXPERIMENTAL=1 cosign clean "$image_tag"
162162

163163
COSIGN_EXPERIMENTAL=1 cosign attest --type spdxjson \
164-
--predicate "${image_tag//:/_}.spdx.json" \
164+
--predicate "${image_tag//[:\/]/_}.spdx.json" \
165165
--yes \
166166
"$image_tag"
167167
fi

0 commit comments

Comments
 (0)