Skip to content

Commit bcebbe4

Browse files
authored
fix: sbom release issue
1 parent f61dd11 commit bcebbe4

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

build/ci/release.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ variables:
3939
SILKBOMB_TAG: "2.0"
4040
SILKBOMB_REGISTRY: "901841024863.dkr.ecr.us-east-1.amazonaws.com"
4141
SILKBOMB_IMAGE: "901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0"
42-
SILKBOMB_PURLS_FILE: "/pwd/purls.txt"
43-
SILKBOMB_SBOM_FILE: "/pwd/sbom.json"
42+
SILKBOMB_PURLS_FILE: "purls.txt"
43+
SILKBOMB_SBOM_FILE: "sbom.json"
4444
- &kondukto_config
45-
AUGMENTED_SILKBOMB_SBOM_FILE: "/pwd/augmented-sbom.json"
45+
AUGMENTED_SILKBOMB_SBOM_FILE: "augmented-sbom.json"
4646
KONDUKTO_CREDENTIALS_FILE: kondukto_credentials.env
4747
KONDUKTO_REPO: mongodb_atlas-cli-plugin-kubernetes
4848
KONDUKTO_BRANCH: test
@@ -125,6 +125,24 @@ functions:
125125
shell: bash
126126
script: |
127127
./upload-sbom.sh
128+
"move sboms":
129+
- command: shell.exec
130+
params:
131+
shell: bash
132+
working_dir: src/github.com/mongodb/atlas-cli-plugin-kubernetes
133+
script: |
134+
if [[ ! -f ./build/package/sbom.json ]]; then
135+
echo "ERROR: sbom.json not found in ./build/package/"
136+
exit 1
137+
fi
138+
if [[ ! -f ./build/package/augmented-sbom.json ]]; then
139+
echo "ERROR: augmented-sbom.json not found in ./build/package/"
140+
exit 1
141+
fi
142+
143+
mv ./build/package/sbom.json sbom.json
144+
mv ./build/package/augmented-sbom.json augmented-sbom.json
145+
echo "Moved SBOMs to repository root."
128146
"package":
129147
- command: github.generate_token
130148
params:
@@ -226,6 +244,7 @@ tasks:
226244
commands:
227245
- func: "generate sbom"
228246
- func: "upload sbom"
247+
- func: "move sboms"
229248
- name: test-trace
230249
tags: ["code_health"]
231250
allowed_requesters: ["patch"]
@@ -253,6 +272,7 @@ tasks:
253272
- func: "generate sbom"
254273
- func: "upload sbom"
255274
- func: "generate notices"
275+
- func: "move sboms"
256276
- func: "install goreleaser"
257277
- func: "install macos notarization service"
258278
- func: "install gh-token"

build/package/generate-sbom.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ set -Eeou pipefail
2020
: "${SILKBOMB_PURLS_FILE:?Missing SILKBOMB_PURLS_FILE}"
2121
: "${SILKBOMB_SBOM_FILE:?Missing SILKBOMB_SBOM_FILE}"
2222

23-
# Check if SILKBOMB_IMAGE is set and available locally
23+
# Resolve absolute path of the purls file directory
24+
PURLS_DIR="$(cd "$(dirname "${SILKBOMB_PURLS_FILE}")" && pwd)"
25+
26+
# Check if image exists locally
2427
if podman image exists "${SILKBOMB_IMAGE}"; then
2528
echo "Using existing local image: ${SILKBOMB_IMAGE}"
2629
else # Else image will need to be pulled from AWS registry
@@ -37,10 +40,10 @@ fi
3740
echo "Generating SBOMs with image: ${SILKBOMB_IMAGE}"
3841
podman run --rm \
3942
--pull=missing \
40-
-v "$(pwd):/pwd" \
43+
-v "${PURLS_DIR}:/pwd" \
4144
"${SILKBOMB_IMAGE}" \
4245
update \
43-
--purls "${SILKBOMB_PURLS_FILE}" \
44-
--sbom-out "${SILKBOMB_SBOM_FILE}"
46+
--purls "/pwd/$(basename "${SILKBOMB_PURLS_FILE}")" \
47+
--sbom-out "/pwd/$(basename "${SILKBOMB_SBOM_FILE}")"
4548

4649
echo "SBOM generated at ${SILKBOMB_SBOM_FILE}"

build/package/upload-sbom.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ set -Eeou pipefail
2222
: "${KONDUKTO_REPO:?Missing KONDUKTO_REPO}"
2323
: "${KONDUKTO_BRANCH:?Missing KONDUKTO_BRANCH}"
2424

25+
# Resolve the absolute directory containing the SBOM file
26+
SBOM_DIR="$(cd "$(dirname "${SILKBOMB_SBOM_FILE}")" && pwd)"
27+
2528
# load the token
2629
if [[ ! -s "${KONDUKTO_CREDENTIALS_FILE}" ]]; then
2730
echo "ERROR: credentials file is missing or empty: ${KONDUKTO_CREDENTIALS_FILE}" >&2
@@ -41,28 +44,28 @@ else # Else image will need to be pulled from AWS registry
4144
podman login --username AWS --password-stdin "${SILKBOMB_REGISTRY}"
4245
fi
4346

44-
# Note, augment by default uploads to Kondukto
45-
if [[ -n "${AUGMENTED_SILKBOMB_SBOM_FILE}" ]]; then
47+
# Upload or augment
48+
if [[ -n "${AUGMENTED_SILKBOMB_SBOM_FILE:-}" ]]; then
4649
echo "Uploading SBOM to Kondukto and outputting augmented version..."
4750
podman run --rm \
4851
--pull=missing \
49-
-v "$(pwd):/pwd" \
52+
-v "${SBOM_DIR}:/pwd" \
5053
--env-file "${KONDUKTO_CREDENTIALS_FILE}" \
5154
"${SILKBOMB_IMAGE}" \
5255
augment \
53-
--sbom-in "${SILKBOMB_SBOM_FILE}" \
54-
--sbom-out "${AUGMENTED_SILKBOMB_SBOM_FILE}" \
56+
--sbom-in "/pwd/$(basename "${SILKBOMB_SBOM_FILE}")" \
57+
--sbom-out "/pwd/$(basename "${AUGMENTED_SILKBOMB_SBOM_FILE}")" \
5558
--repo "${KONDUKTO_REPO}" \
5659
--branch "${KONDUKTO_BRANCH}"
5760
else
5861
echo "Uploading SBOM to Kondukto..."
5962
podman run --rm \
6063
--pull=missing \
61-
-v "$(pwd):/pwd" \
64+
-v "${SBOM_DIR}:/pwd" \
6265
--env-file "${KONDUKTO_CREDENTIALS_FILE}" \
6366
"${SILKBOMB_IMAGE}" \
6467
upload \
65-
--sbom-in "${SILKBOMB_SBOM_FILE}" \
68+
--sbom-in "/pwd/$(basename "${SILKBOMB_SBOM_FILE}")" \
6669
--repo "${KONDUKTO_REPO}" \
6770
--branch "${KONDUKTO_BRANCH}"
6871
fi

0 commit comments

Comments
 (0)