Skip to content

Commit d413bc2

Browse files
authored
CLOUDP-327046/sbom-fixes (#96)
* fix: sbom.json should be part of .gitignore * feat: allow for augmented sboms
1 parent 3aaebd6 commit d413bc2

File tree

6 files changed

+39
-18
lines changed

6 files changed

+39
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ manifest.windows.yml
2929
gon_x86_64.json
3030
gon_arm64.json
3131
*.xml
32+
sbom.json
33+
augmented-sbom.json
3234

3335
# We don't want to commit env variables
3436
*.env

build/ci/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ variables:
4242
SILKBOMB_PURLS_FILE: "/pwd/purls.txt"
4343
SILKBOMB_SBOM_FILE: "/pwd/sbom.json"
4444
- &kondukto_config
45+
AUGMENTED_SILKBOMB_SBOM_FILE: "/pwd/augmented-sbom.json"
4546
KONDUKTO_CREDENTIALS_FILE: kondukto_credentials.env
4647
KONDUKTO_REPO: mongodb_atlas-cli-plugin-kubernetes
4748
KONDUKTO_BRANCH: test

build/package/.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ release:
9292
extra_files:
9393
- glob: ./*.asc
9494
- glob: ./sbom.json
95+
- glob: ./augmented-sbom.json

build/package/generate-sbom.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
set -Eeou pipefail
1818

1919
: "${SILKBOMB_IMAGE:?Missing SILKBOMB_IMAGE}"
20+
: "${SILKBOMB_PURLS_FILE:?Missing SILKBOMB_PURLS_FILE}"
21+
: "${SILKBOMB_SBOM_FILE:?Missing SILKBOMB_SBOM_FILE}"
2022

2123
# Check if SILKBOMB_IMAGE is set and available locally
2224
if podman image exists "${SILKBOMB_IMAGE}"; then
@@ -25,6 +27,7 @@ else # Else image will need to be pulled from AWS registry
2527
: "${AWS_ACCESS_KEY_ID:?Missing AWS_ACCESS_KEY_ID}"
2628
: "${AWS_SECRET_ACCESS_KEY:?Missing AWS_SECRET_ACCESS_KEY}"
2729
: "${AWS_SESSION_TOKEN:?Missing AWS_SESSION_TOKEN}"
30+
: "${SILKBOMB_REGISTRY:?Missing SILKBOMB_REGISTRY}"
2831

2932
echo "Logging in to ECR..."
3033
aws ecr get-login-password --region us-east-1 | \

build/package/package.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@ export VERSION
2828

2929
make generate-all-manifests
3030

31-
"${test_mode:=false}"
32-
3331
# If test mode is set, do not create a release on GitHub, just package locally
34-
if [[ "${test_mode}" == "true" ]]; then
35-
# avoid race conditions on the notarization step by using `-p 1`
32+
if [[ "${test_mode:-false}" == "true" ]]; then
33+
# avoid race conditions on the notarization step by using `-p 1`
3634
./bin/goreleaser release --snapshot --config "build/package/.goreleaser.yml" --clean -p 1
37-
else
35+
else
3836
# avoid race conditions on the notarization step by using `-p 1`
3937
./bin/goreleaser release --config "build/package/.goreleaser.yml" --clean -p 1
40-
fi
38+
fi
4139

4240
# check that the notarization service signed the mac binaries
4341
SIGNED_FILE_NAME=atlas-cli-plugin-kubernetes_macos_signed.zip

build/package/upload-sbom.sh

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
set -Eeou pipefail
1818

1919
: "${SILKBOMB_IMAGE:?Missing SILKBOMB_IMAGE}"
20+
: "${SILKBOMB_SBOM_FILE:?Missing SILKBOMB_SBOM_FILE}"
2021
: "${KONDUKTO_CREDENTIALS_FILE:?Missing KONDUKTO_CREDENTIALS_FILE}"
2122
: "${KONDUKTO_REPO:?Missing KONDUKTO_REPO}"
2223
: "${KONDUKTO_BRANCH:?Missing KONDUKTO_BRANCH}"
@@ -33,22 +34,37 @@ else # Else image will need to be pulled from AWS registry
3334
: "${AWS_ACCESS_KEY_ID:?Missing AWS_ACCESS_KEY_ID}"
3435
: "${AWS_SECRET_ACCESS_KEY:?Missing AWS_SECRET_ACCESS_KEY}"
3536
: "${AWS_SESSION_TOKEN:?Missing AWS_SESSION_TOKEN}"
37+
: "${SILKBOMB_REGISTRY:?Missing SILKBOMB_REGISTRY}"
3638

3739
echo "Logging in to ECR..."
3840
aws ecr get-login-password --region us-east-1 | \
3941
podman login --username AWS --password-stdin "${SILKBOMB_REGISTRY}"
4042
fi
4143

42-
echo "Uploading SBOM to Kondukto..."
43-
podman run --rm \
44-
--pull=missing \
45-
-v "$(pwd):/pwd" \
46-
--env-file "${KONDUKTO_CREDENTIALS_FILE}" \
47-
"${SILKBOMB_IMAGE}" \
48-
upload \
49-
--sbom-in "${SILKBOMB_SBOM_FILE}" \
50-
--repo "${KONDUKTO_REPO}" \
51-
--branch "${KONDUKTO_BRANCH}"
52-
53-
echo "Uploading complete."
44+
# Note, augment by default uploads to Kondukto
45+
if [[ -n "${AUGMENTED_SILKBOMB_SBOM_FILE}" ]]; then
46+
echo "Uploading SBOM to Kondukto and outputting augmented version..."
47+
podman run --rm \
48+
--pull=missing \
49+
-v "$(pwd):/pwd" \
50+
--env-file "${KONDUKTO_CREDENTIALS_FILE}" \
51+
"${SILKBOMB_IMAGE}" \
52+
augment \
53+
--sbom-in "${SILKBOMB_SBOM_FILE}" \
54+
--sbom-out "${AUGMENTED_SILKBOMB_SBOM_FILE}" \
55+
--repo "${KONDUKTO_REPO}" \
56+
--branch "${KONDUKTO_BRANCH}"
57+
else
58+
echo "Uploading SBOM to Kondukto..."
59+
podman run --rm \
60+
--pull=missing \
61+
-v "$(pwd):/pwd" \
62+
--env-file "${KONDUKTO_CREDENTIALS_FILE}" \
63+
"${SILKBOMB_IMAGE}" \
64+
upload \
65+
--sbom-in "${SILKBOMB_SBOM_FILE}" \
66+
--repo "${KONDUKTO_REPO}" \
67+
--branch "${KONDUKTO_BRANCH}"
68+
fi
69+
5470
rm -f "${KONDUKTO_CREDENTIALS_FILE}"

0 commit comments

Comments
 (0)