Skip to content

Commit f5941d3

Browse files
authored
CLOUDP-251873: Decouple SBOMs from checklist (#1634)
* CLOUDP-251873: Decouple SBOMs from SSDLC checklist & automate Signed-off-by: jose.vazquez <[email protected]> * Use a var for reviewers --------- Signed-off-by: jose.vazquez <[email protected]>
1 parent 913ede5 commit f5941d3

File tree

8 files changed

+112
-34
lines changed

8 files changed

+112
-34
lines changed

.github/workflows/release-branch.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
version:
1010
description: "Release version:"
1111
required: true
12+
authors:
13+
description: "Comma separated list of the release authors' emails"
14+
required: true
1215

1316
jobs:
1417
create-release-branch:
@@ -17,6 +20,7 @@ jobs:
1720
env:
1821
VERSION: ${{ github.event.inputs.version }}
1922
TAG: v${{ github.event.inputs.version }}
23+
AUTHORS: ${{ github.event.inputs.authors }}
2024
GITHUB_REPO: mongodb/mongodb-atlas-kubernetes
2125
DOCKER_RELEASE_REPO: mongodb/mongodb-atlas-kubernetes-operator
2226
steps:
@@ -40,8 +44,11 @@ jobs:
4044
cache: false
4145

4246
- name: Download dependencies
47+
run: go mod download
48+
49+
- name: Generate SDLC checklist files for released version
4350
run: |
44-
go mod download
51+
make gen-sdlc-checklist VERSION=${{ env.VERSION }} AUTHORS=${{ env.AUTHORS }}
4552
4653
- name: Configure Git
4754
run: |
@@ -63,5 +70,6 @@ jobs:
6370
uses: ./.github/actions/create-pr
6471
env:
6572
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
REVIEWERS: ${{ env.REVIEWERS }}
6674
with:
67-
REVIEWERS: igor-karpukhin,helderjs,josvazg,roothorp
75+
REVIEWERS: ${{ env.REVIEWERS }}

.github/workflows/release-post-merge.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,22 @@ jobs:
225225
asset_path: ./atlas-operator-all-in-one-${{ steps.tag.outputs.version }}.tar.gz
226226
asset_name: atlas-operator-all-in-one-${{ steps.tag.outputs.version }}.tar.gz
227227
asset_content_type: application/tgz
228+
229+
- name: Create SBOMs branch
230+
env:
231+
BRANCH: version-${{ steps.tag.outputs.version }}-sboms
232+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
233+
run: |
234+
make generate-sboms VERSION=${{ steps.tag.outputs.version }}
235+
git checkout -b $BRANCH
236+
git add .
237+
git commit -m "Add SBOMs for version ${{ steps.tag.outputs.version }}"
238+
git push --set-upstream origin $BRANCH
239+
240+
- name: Create SBOMs PR
241+
uses: ./.github/actions/create-pr
242+
env:
243+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244+
REVIEWERS: ${{ env.REVIEWERS }}
245+
with:
246+
REVIEWERS: ${{ env.REVIEWERS }}

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ REGISTRY ?= quay.io/mongodb
5353
BUNDLE_IMG ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease-bundle:$(VERSION)
5454

5555
#BUNDLE_REGISTRY ?= $(REGISTRY)/mongodb-atlas-operator-bundle
56+
RELEASED_OPERATOR_IMAGE ?= mongodb/mongodb-atlas-kubernetes-operator
5657
OPERATOR_REGISTRY ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease
5758
CATALOG_REGISTRY ?= $(REGISTRY)/mongodb-atlas-kubernetes-operator-prerelease-catalog
5859
OPERATOR_IMAGE ?= ${OPERATOR_REGISTRY}:${VERSION}
@@ -491,10 +492,15 @@ docker-sbom:
491492
@docker sbom --help > /dev/null || \
492493
echo "You might need to install the SBOM plugin for docker, check out docs/dev/release.md#tools"
493494

495+
.PHONY: generate-sboms
496+
generate-sboms: docker-sbom ## Generate a released version SBOMs
497+
@mkdir -p docs/releases/v$(VERSION) && \
498+
./scripts/generate_upload_sbom.sh -i $(RELEASED_OPERATOR_IMAGE):$(VERSION) -o docs/releases/v$(VERSION) && \
499+
ls -l docs/releases/v$(VERSION)
500+
494501
.PHONY: gen-sdlc-checklist
495-
gen-sdlc-checklist: envsubst docker-sbom ## Generate the SDLC checklist
496-
@VERSION="$(VERSION)" AUTHORS="$(AUTHORS)" RELEASE_TYPE="$(RELEASE_TYPE)" \
497-
./scripts/gen-sdlc-checklist.sh
502+
gen-sdlc-checklist: envsubst ## Generate the SDLC checklist
503+
@VERSION="$(VERSION)" AUTHORS="$(AUTHORS)" ./scripts/gen-sdlc-checklist.sh
498504

499505
# TODO: avoid leaving leftovers in the first place
500506
.PHONY: clear-e2e-leftovers

docs/dev/image-sboms.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Image SBOMs
2+
3+
Starting from version 2.2.0 and onward, all Atlas Kubernetes Operator images are attached SBOMs files per image platform released. SBOM stands for Software Bill Of Materials, a recursive list of all dependencies within of a software binary or image image that is useful to evaluate potential security vulnerabilities that might be affected that particular version.
4+
5+
These SBOMs attached after release, as they need the images to be published for the SBOMs to be computed.
6+
7+
This document describes how the project computes those SBOMs as well as how end users can compute them on their own.
8+
9+
## Scripts computing the SBOMs for the CI
10+
11+
The main script to check is [scripts/generate_upload_sbom.sh](../../scripts/generate_upload_sbom.sh):
12+
13+
```shell
14+
$ ./scripts/generate_upload_sbom.sh -h
15+
Generates and uploads an SBOM to an S3 bucket.
16+
17+
Usage:
18+
generate_upload_sbom.sh [-h]
19+
generate_upload_sbom.sh -i <image_name>
20+
21+
Options:
22+
-h (optional) Shows this screen.
23+
-i <image_name> (required) Image to be processed.
24+
-b (optional) S3 bucket name.
25+
-p (optional) An array of platforms, for example 'linux/arm64,linux/amd64'. The script **doesn't** fail if a particular architecture is not found.
26+
-o <output_folder> (optional) Folder to output SBOM to.
27+
```
28+
29+
As you can see one what you use it will be:
30+
31+
```shell
32+
$ ./scripts/generate_upload_sbom.sh -i mongodb/mongodb-atlas-kubernetes-operator:2.3.0
33+
```
34+
35+
When given no platforms it will default to `linux/amd64` & `linux/arm64` and try to download them and produce the SBOMS files.
36+
37+
## DIY SBOMs
38+
39+
To compute the SBOMs manually the only complication, other than having `docker` with the `sbom` plug-in installed, is that to get SBOMs from multi-architecture images require the full SHA nomenclature to successfully produce the SBOM regardless of the host architecture the `docker sbom` where command is run. The gist of it getting the SHA of the desired platform and then getting the SBOM for that particular image SHA:
40+
41+
```shell
42+
export digest=$(docker manifest inspect "${img}" |jq -r '.manifests[] | select(.platform.os == "'"${os}"'" and .platform.architecture=="'"${arch}"'") | .digest')
43+
docker sbom --platform "${os}/${arch}" --format "cyclonedx-json" "${img}@${digest}"
44+
```
45+
46+
For example:
47+
```shell
48+
$ export os=linux
49+
$ export arch=amd64
50+
$ export img=mongodb/mongodb-atlas-kubernetes-operator:2.3.0
51+
$ export digest=$(docker manifest inspect "${img}" |jq -r '.manifests[] | select(.platform.os == "'"${os}"'" and .platform.architecture=="'"${arch}"'") | .digest')
52+
$ docker sbom --platform "${os}/${arch}" --format "cyclonedx-json" "${img}@${digest}"
53+
{
54+
"bomFormat": "CycloneDX",
55+
"specVersion": "1.4",
56+
...
57+
```

docs/dev/release.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ Most tools are automatically installed for you. Most of them are Go binaries and
1919

2020
## Create the release branch
2121

22-
Use the GitHub UI to create the new "Create Release Branch" workflow. Specify the version to be released in the text box.
22+
Use the GitHub UI to create the new "Create Release Branch" workflow. Specify the `version` to be released in the text box and the author or `authors` involved in the release.
2323
The deployment scripts (K8s configs, OLM bundle) will be generated and PR will be created with new changes on behalf
2424
of the `github-actions` bot.
2525

2626
Pass the version with the `X.Y.Z` eg. `1.2.3`, **without** the `v...` prefix.
2727

2828
See [Troubleshooting](#troubleshooting) in case of issues, such as [errors with the major version](#major-version-issues-when-create-release-branch).
2929

30+
Expect this branch to include the Software Security Development Lifecycle Policy Checklist (SSDLC) document at path `docs/releases/v${VERSION}/sdlc-compliance.md`. Note the SBOM files cannot be generated yet, as they require the image to have been published already.
31+
3032
## Approve the Pull Request named "Release x.y.z"
3133

3234
Review the Pull Request. Approve and merge it to `main`.
@@ -36,6 +38,12 @@ The new job "Create Release" will be triggered and the following will be done:
3638

3739
The "Create Release Branch" workflow is going to create a Pull Request pointing to a `release/X.Y.Z` branch. Once approved and merged, automation is going to create a `vX.Y.Z` tag.
3840

41+
### SSDLC SBOMs PR
42+
43+
A new PR should have been created titled `Add SBOMs for version ...`. Please review all is as expected and merge. It should contain just a couple of new files at directory `docs/releases/v${VERSION}/`:
44+
- `linux-amd64.sbom.json`
45+
- `linux-arm64.sbom.json`
46+
3947
## Edit the Release Notes and publish the release
4048

4149
Follow the format described in the [release-notes-template.md](../release-notes/release-notes-template.md) file. Before publishing the release, keep the release in Draft and get an approval from the team and Product Management. Once approved, publish the release.
@@ -160,29 +168,11 @@ You can see an [example fixed PR here for certified version 1.9.1](https://githu
160168

161169
After the PR is approved it will soon appear in the [Atlas Operator openshift cluster](https://console-openshift-console.apps.atlas.operator.mongokubernetes.com)
162170

163-
# SSDLC checklist publishing
164-
165-
You can create the draft for the SSDLC checklist just by running:
166-
167-
```shell
168-
$ DATE= VERSION="${version}" AUTHORS="${release_authors}" RELEASE_TYPE= make gen-sdlc-checklist
169-
```
170-
171-
- You can leave `DATE` unset so the script may use today's date.
172-
- `RELEASE_TYPE` is also optional defaulting to `Minor` releases, set to `Major`when appropriate.
173-
174-
The script generates the directory `docs/releases/v${VERSION}/` with files:
175-
- `linux-amd64.sbom.json`
176-
- `linux-arm64.sbom.json`
177-
- `sdlc-compliance.md`
178-
179-
Add those files to `git`, and create a PR to review the changes to close the release.
180-
181171
# Post install hook release
182172

183173
If changes have been made to the post install hook (mongodb-atlas-kubernetes/cmd/post-install/main.go).
184174
You must also release this image. Run the "Release Post Install Hook" workflow manually specifying the desired
185-
release version.
175+
release version.
186176

187177
# Post Release actions
188178

docs/releases/sdlc-compliance.template.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ Overview:
99
- **Product and Release Name**
1010

1111
- Atlas Kubernetes Operator v${VERSION}, ${DATE}.
12-
- Release Type: ${RELEASE_TYPE}
1312

1413
- **Process Document**
1514
- http://go/how-we-develop-software-doc
1615

1716
- **Tool used to track third party vulnerabilities**
18-
- Silk
17+
- [Silk](https://www.silk.security/)
1918

2019
- **Dependency Information**
21-
- See SBOMS Lite manifests (CycloneDX in JSON format) for [Intel](./linux-amd64.sbom.json) or [ARM](./linux-arm64.sbom.json)
20+
- See SBOMS Lite manifests (CycloneDX in JSON format) for `Intel` and `ARM` are to be found [here](.)
21+
- See [instructions on how the SBOMs are generated or how to generate them manually](../../dev/image-sboms.md)
22+
- [Internal compliance folder](https://drive.google.com/drive/folders/1k0TsPgJcMwgj2muSPHU0FHHBjPT0dkS0?usp=drive_link)
2223

2324
- **Static Analysis Report**
2425
- No SAST findings. Our CI system blocks merges on any SAST findings.${IGNORED_VULNERABILITIES}

scripts/gen-sdlc-checklist.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set -eu
44

55
release_date=${DATE:-$(date -u '+%Y-%m-%d')}
66
release_type=${RELEASE_TYPE:-Minor}
7-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
87

98
export DATE="${release_date}"
109
export VERSION="${VERSION}"
@@ -20,9 +19,7 @@ else
2019
fi
2120
export IGNORED_VULNERABILITIES="${ignored_list}"
2221

23-
img="mongodb/mongodb-atlas-kubernetes-operator:${VERSION}"
24-
"${SCRIPT_DIR}"/generate_upload_sbom.sh -i "$img" -o "docs/releases/v${VERSION}"
25-
22+
mkdir -p "docs/releases/v${VERSION}/"
2623
envsubst < docs/releases/sdlc-compliance.template.md \
2724
> "docs/releases/v${VERSION}/sdlc-compliance.md"
2825

scripts/generate_upload_sbom.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ function usage() {
1616
1717
Usage:
1818
generate_upload_sbom.sh [-h]
19-
generate_upload_sbom.sh -i <image_name> -b <bucket_name>
19+
generate_upload_sbom.sh -i <image_name>
2020
2121
Options:
2222
-h (optional) Shows this screen.
2323
-i <image_name> (required) Image to be processed.
24-
-b (required) S3 bucket name.
24+
-b (optional) S3 bucket name.
2525
-p (optional) An array of platforms, for example 'linux/arm64,linux/amd64'. The script **doesn't** fail if a particular architecture is not found.
2626
-o <output_folder> (optional) Folder to output SBOM to.
2727
"

0 commit comments

Comments
 (0)