Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions publish-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,20 @@ runs:
# Extract the digest from the image repo digest (right side of '@')
DIGEST=${IMAGE_REPO_DIGEST#*@}

# URL encode the digest and image repository, needed for the purl
URLENCODED_DIGEST=$(jq -rn --arg input "$DIGEST" '$input | @uri')
URLENCODED_IMAGE_REPOSITORY=$(jq -rn --arg input "$IMAGE_REPOSITORY" '$input | @uri')
# Last item, split by /
# Example: sdp/kafka -> kafka
SOURCE_NAME=$(echo "$IMAGE_REPOSITORY" | awk -F'/' '{print $NF}')
# Extract architecture from image tag
ARCH=$(echo "$IMAGE_MANIFEST_TAG" | awk -F'-' '{print $NF}')
if [ "$ARCH" != "amd64" ] && [ "$ARCH" != "arm64" ]; then
echo "Invalid architecture obtained from image tag. IMAGE_MANIFEST_TAG: $IMAGE_MANIFEST_TAG, ARCH: $ARCH"
exit 1
fi
# Construct the package url (purl)
# TODO (@Techassi): Can we use 'oci' instead of 'docker' as the type?
PURL="pkg:docker/$IMAGE_REPOSITORY@$DIGEST?repository_url=$REGISTRY_URI"
PURL="pkg:oci/{$SOURCE_NAME}@{$URLENCODED_DIGEST}?arch=${ARCH}&repository_url=${REGISTRY_URI}%2F${URLENCODED_IMAGE_REPOSITORY}"

# Get metadata from the image
# NOTE (@Techassi): Maybe we should run this command only once
Expand All @@ -123,7 +134,7 @@ runs:
--output [email protected]=sbom_raw.json \
--select-catalogers "-cargo-auditable-binary-cataloger,+sbom-cataloger" \
--scope all-layers \
--source-name "$IMAGE_REPOSITORY" \
--source-name "$SOURCE_NAME" \
--source-version "$IMAGE_MANIFEST_TAG" "${IMAGE_REPO_DIGEST}"

# Merge SBOM components using https://github.com/stackabletech/mergebom
Expand Down
Loading