Skip to content

Commit 95f8281

Browse files
authored
MONGOCRYPT-777 update scripts and release instructions for SilkBomb 2.0 (#964)
* Remove silk-create-asset-group.sh * Remove Earthly sbom-download * Update Earthly targets and commands for SilkBomb 2.0 * Update release instructions for SilkBomb 2.0
1 parent 0110c05 commit 95f8281

File tree

5 files changed

+149
-132
lines changed

5 files changed

+149
-132
lines changed

.evergreen/config.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,55 @@ functions:
388388
# Earthly hardcodes use of docker/dockerfile-copy:v0.1.9 for the CACHE command.
389389
bash ${workdir}/libmongocrypt/.evergreen/earthly.sh ${args} --persist-build=false
390390
391+
sbom:
392+
- command: ec2.assume_role
393+
type: setup
394+
params:
395+
role_arn: ${kondukto_role_arn}
396+
- command: subprocess.exec
397+
type: setup
398+
params:
399+
binary: bash
400+
include_expansions_in_env:
401+
- AWS_ACCESS_KEY_ID
402+
- AWS_SECRET_ACCESS_KEY
403+
- AWS_SESSION_TOKEN
404+
args:
405+
- -c
406+
- |
407+
set -o errexit
408+
set -o pipefail
409+
kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)"
410+
printf "KONDUKTO_TOKEN: %s\n" "$kondukto_token" >|expansions.kondukto.yml
411+
- command: expansions.update
412+
type: setup
413+
params:
414+
file: expansions.kondukto.yml
415+
- command: subprocess.exec
416+
type: test
417+
params:
418+
binary: bash
419+
working_dir: libmongocrypt
420+
include_expansions_in_env:
421+
- artifactory_password
422+
- artifactory_username
423+
- branch_name
424+
- KONDUKTO_TOKEN
425+
args:
426+
- -c
427+
- .evergreen/sbom.sh
428+
- command: s3.put
429+
type: test
430+
params:
431+
display_name: Augmented SBOM
432+
aws_key: ${aws_key}
433+
aws_secret: ${aws_secret}
434+
bucket: mciuploads
435+
content_type: application/json
436+
local_file: libmongocrypt/cyclonedx.augmented.sbom.json
437+
permissions: public-read
438+
remote_file: ${project}/${build_variant}/${branch_name}/${libmongocrypt_s3_suffix}/sbom/cyclonedx.augmented.sbom.json
439+
391440
tasks:
392441
- name: build-and-test-and-upload
393442
commands:
@@ -994,6 +1043,11 @@ tasks:
9941043
params:
9951044
file: libmongocrypt/bindings/python/results.json
9961045

1046+
- name: sbom
1047+
commands:
1048+
- func: fetch source
1049+
- func: sbom
1050+
9971051
pre:
9981052
# Update the evergreen expansion to dynamically set the ${libmongocrypt_s3_suffix} and ${libmongocrypt_s3_suffix_copy} expansions.
9991053
- command: "shell.exec"
@@ -1586,3 +1640,10 @@ buildvariants:
15861640
- name: publish-deb-packages-with-earthly
15871641
# Use a distro suitable for running curator to publish .deb packages.
15881642
run_on: ubuntu2004-small
1643+
1644+
- name: sbom
1645+
display_name: SBOM
1646+
tasks:
1647+
- name: sbom
1648+
# Just for high host availability. Not platform-specific.
1649+
run_on: rhel80

.evergreen/sbom.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
: "${artifactory_username:?}"
7+
: "${artifactory_password:?}"
8+
: "${branch_name:?}"
9+
: "${KONDUKTO_TOKEN:?}"
10+
11+
command -v podman >/dev/null || {
12+
echo "missing required program podman" 1>&2
13+
exit 1
14+
}
15+
16+
podman login --password-stdin --username "${artifactory_username:?}" artifactory.corp.mongodb.com <<<"${artifactory_password:?}"
17+
18+
silkbomb="artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:2.0"
19+
20+
# Ensure latest version of SilkBomb is being used.
21+
podman pull "${silkbomb:?}"
22+
23+
silkbomb_augment_flags=(
24+
--repo mongodb/libmongocrypt
25+
--branch "${branch_name:?}"
26+
--sbom-in /pwd/etc/cyclonedx.sbom.json
27+
--sbom-out /pwd/cyclonedx.augmented.sbom.json
28+
29+
# Any notable updates to the Augmented SBOM version should be done manually after careful inspection.
30+
# Otherwise, it should be equal to the SBOM Lite version, which should normally be `1`.
31+
--no-update-sbom-version
32+
)
33+
34+
# First validate the SBOM Lite.
35+
podman run -it --rm -v "$(pwd):/pwd" "${silkbomb:?}" \
36+
validate --purls /pwd/etc/purls.txt --sbom-in /pwd/etc/cyclonedx.sbom.json --exclude jira
37+
38+
# Then download the Augmented SBOM. Allow the timestamp to be updated.
39+
podman run -it --rm -v "$(pwd):/pwd" --env 'KONDUKTO_TOKEN' "${silkbomb:?}" \
40+
augment "${silkbomb_augment_flags[@]:?}"
41+
42+
[[ -f ./cyclonedx.augmented.sbom.json ]] || {
43+
echo "failed to download Augmented SBOM" 1>&2
44+
exit 1
45+
}

Earthfile

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -462,62 +462,60 @@ sign:
462462
#
463463
# See https://docs.devprod.prod.corp.mongodb.com/mms/python/src/sbom/silkbomb/ for documentation of silkbomb.
464464
silkbomb:
465-
FROM artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0
466-
# Alias the silkbom executable to a simpler name:
465+
FROM artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:2.0
466+
# Alias the silkbomb executable to a simpler name:
467467
RUN ln -s /python/src/sbom/silkbomb/bin /usr/local/bin/silkbomb
468468

469469
# sbom-generate:
470470
# Generate/update the etc/cyclonedx.sbom.json file from the etc/purls.txt file.
471471
#
472472
# This target will update the existing etc/cyclonedx.sbom.json file in-place based
473-
# on the content of etc/purls.txt.
474-
#
473+
# on the content of etc/purls.txt and etc/cyclonedx.sbom.json.
475474
sbom-generate:
476475
FROM +silkbomb
477476
# Copy in the relevant files:
478477
WORKDIR /s
479478
COPY etc/purls.txt etc/cyclonedx.sbom.json /s/
480479
# Update the SBOM file:
481480
RUN silkbomb update \
481+
--refresh \
482+
--no-update-sbom-version \
482483
--purls purls.txt \
483484
--sbom-in cyclonedx.sbom.json \
484485
--sbom-out cyclonedx.sbom.json
485486
# Save the result back to the host:
486487
SAVE ARTIFACT /s/cyclonedx.sbom.json AS LOCAL etc/cyclonedx.sbom.json
487488

488-
# sbom-download:
489-
# Download the Augmented SBOM file from Silk.
490-
#
491-
# See https://wiki.corp.mongodb.com/display/DRIVERS/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets for instructions to get secrets from AWS Secrets Manager. Secrets are available under `drivers/libmongocrypt`.
489+
# sbom-generate-new-serial-number:
490+
# Equivalent to +sbom-generate but includes the --generate-new-serial-number
491+
# flag to generate a new unique serial number and reset the SBOM version to 1.
492492
#
493-
sbom-download:
494-
ARG --required out
495-
ARG --required branch
493+
# This target will update the existing etc/cyclonedx.sbom.json file in-place based
494+
# on the content of etc/purls.txt and etc/cyclonedx.sbom.json.
495+
sbom-generate-new-serial-number:
496496
FROM +silkbomb
497+
# Copy in the relevant files:
497498
WORKDIR /s
498-
# Download the Augmented SBOM file:
499-
RUN --no-cache --secret silk_client_id --secret silk_client_secret \
500-
SILK_CLIENT_ID=${silk_client_id} \
501-
SILK_CLIENT_SECRET=${silk_client_secret} \
502-
silkbomb download \
503-
--sbom-out cyclonedx.augmented.sbom.json \
504-
--silk-asset-group libmongocrypt-${branch}
499+
COPY etc/purls.txt etc/cyclonedx.sbom.json /s/
500+
# Update the SBOM file:
501+
RUN silkbomb update \
502+
--refresh \
503+
--generate-new-serial-number \
504+
--purls purls.txt \
505+
--sbom-in cyclonedx.sbom.json \
506+
--sbom-out cyclonedx.sbom.json
505507
# Save the result back to the host:
506-
SAVE ARTIFACT /s/cyclonedx.augmented.sbom.json AS LOCAL ${out}
507-
RUN echo "Augmented SBOM saved to ${out}"
508+
SAVE ARTIFACT /s/cyclonedx.sbom.json AS LOCAL etc/cyclonedx.sbom.json
508509

509-
# silk-create-asset-group:
510-
# Create an asset group for Silk.
511-
#
512-
# See https://wiki.corp.mongodb.com/display/DRIVERS/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets for instructions to get secrets from AWS Secrets Manager. Secrets are available under `drivers/libmongocrypt`.
513-
#
514-
silk-create-asset-group:
515-
ARG --required branch
516-
FROM +env.alpine
517-
RUN __install curl jq
518-
COPY etc/silk-create-asset-group.sh /s/silk-create-asset-group.sh
519-
RUN --no-cache --secret silk_client_id --secret silk_client_secret \
520-
silk_client_id=${silk_client_id} \
521-
silk_client_secret=${silk_client_secret} \
522-
branch=${branch} \
523-
/s/silk-create-asset-group.sh
510+
# sbom-validate:
511+
# Validate the SBOM Lite for the given branch.
512+
sbom-validate:
513+
FROM +silkbomb
514+
# Copy in the relevant files:
515+
WORKDIR /s
516+
COPY etc/purls.txt etc/cyclonedx.sbom.json /s/
517+
# Run the SilkBomb tool to download the artifact that matches the requested branch
518+
RUN silkbomb validate \
519+
--purls purls.txt \
520+
--sbom-in cyclonedx.sbom.json \
521+
--exclude jira

doc/releasing.md

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ snyk monitor \
4444

4545
Check the updated reference targets in Snyk for detected vulnerabilities.
4646

47-
#### Check Silk
47+
#### Check the Augmented SBOM
4848

49-
Get credentials for Silk from the `drivers/libmongocrypt` vault in [AWS Secrets Manager](https://wiki.corp.mongodb.com/display/DRIVERS/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets).
49+
Examine the Augmented SBOM from a recent execution of the `sbom` task in an Evergreen patch or commit build.
50+
51+
Evergreen CLI may be used to schedule only the `sbom` task:
5052

51-
Download the Augmented SBOM using:
5253
```bash
53-
./.evergreen/earthly.sh \
54-
--secret silk_client_id=${silk_client_id} \
55-
--secret silk_client_secret=${silk_client_secret} \
56-
+sbom-download \
57-
--out cyclonedx.augmented.sbom.json \
58-
--branch <branch>
54+
# Ensure `-p` matches the correct Evergreen project for the current branch!
55+
evergreen patch -y -p libmongocrypt -t all -v sbom -f
5956
```
6057

6158
Check the contents of the "vulnerabilities" field (if present) in the Augmented SBOM.
@@ -83,29 +80,16 @@ Do the following when releasing:
8380
- If the `publish-packages` tasks fail with an error like `[curator] 2024/01/02 13:56:17 [p=emergency]: problem submitting repobuilder job: 404 (Not Found)`, this suggests the published path does not yet exist. Barque (the Linux package publishing service) has protection to avoid unintentional publishes. File a DEVPROD ticket ([example](https://jira.mongodb.org/browse/DEVPROD-4053)) and assign to the team called Release Infrastructure to request the path be created. Then re-run the failing `publish-packages` task. Ask in the slack channel `#devprod-release-tools` for further help with `Barque` or `curator`.
8481
- Create the release from the GitHub releases page from the new tag.
8582
- Attach the tarball and signature file from the Files tab of the `windows-upload-release` task. [Example](https://github.com/mongodb/libmongocrypt/releases/tag/1.10.0).
86-
- Attach the Augmented SBOM file. Download the Augmented SBOM using:
87-
```bash
88-
./.evergreen/earthly.sh \
89-
--secret silk_client_id=${silk_client_id} \
90-
--secret silk_client_secret=${silk_client_secret} \
91-
+sbom-download \
92-
--out cyclonedx.augmented.sbom.json \
93-
--branch <branch>
94-
```
95-
For a new minor release, use `master` for `--branch`. For a patch release, use the release branch (e.g. `rx.y`).
96-
Secrets can be obtained from [AWS Secrets Manager](https://wiki.corp.mongodb.com/display/DRIVERS/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets) under `drivers/libmongocrypt`.
83+
- Attach the Augmented SBOM file to the release as `cyclonedx.augmented.sbom.json`.
84+
Download the Augmented SBOM from a recent execution of the `sbom` task in an Evergreen patch or commit build.
9785
- Attach `etc/third_party_vulnerabilities.md` to the release.
9886
- Attach `etc/ssdlc_compliance_report.md` to the release.
9987

10088
- If this is a new minor release (e.g. `x.y.0`):
10189
- File a DOCSP ticket to update the installation instructions on [Install libmongocrypt](https://www.mongodb.com/docs/manual/core/csfle/reference/libmongocrypt/). ([Example](https://jira.mongodb.org/browse/DOCSP-36863))
102-
- Create a new Silk asset group. Use the newly created release branch (e.g. `rx.y`) as the `--branch` argument:
90+
- Generate a new unique SBOM serial number for the next release:
10391
```bash
104-
./.evergreen/earthly.sh \
105-
--secret silk_client_id=${silk_client_id} \
106-
--secret silk_client_secret=${silk_client_secret} \
107-
+silk-create-asset-group \
108-
--branch <branch>
92+
./.evergreen/earthly.sh +sbom-generate-new-serial-number
10993
```
11094
- Create a new Snyk reference target. The following instructions use the example branch `rx.y`:
11195

@@ -164,4 +148,3 @@ index 609dc0b..f7530a9 100644
164148
Architectures: amd64 arm64
165149
suites:
166150
```
167-

etc/silk-create-asset-group.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)