Skip to content

Commit 9b5d3ae

Browse files
Merge pull request #2 from jasonhills-mongodb/sbom_github_action
2 parents 8b873ee + acbcdd2 commit 9b5d3ae

File tree

13 files changed

+2317
-119
lines changed

13 files changed

+2317
-119
lines changed

.evergreen/config_generator/components/funcs/install_c_driver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
# If updating mongoc_version_minimum to a new release (not pinning to an unreleased commit), also update:
1010
# - BSON_REQUIRED_VERSION and MONGOC_REQUIRED_VERSION in CMakeLists.txt
11-
# - the version of pkg:github/mongodb/mongo-c-driver in etc/purls.txt
1211
# - the default value of --c-driver-build-ref in etc/make_release.py
1312
# If pinning to an unreleased commit, create a "Blocked" JIRA ticket with
1413
# a "depends on" link to the appropriate C Driver version release ticket.

.evergreen/scripts/sbom.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ podman pull "${silkbomb:?}"
2525
silkbomb_augment_flags=(
2626
--repo mongodb/mongo-cxx-driver
2727
--branch "${branch_name:?}"
28-
--sbom-in /pwd/etc/cyclonedx.sbom.json
28+
--sbom-in /pwd/sbom.json
2929
--sbom-out /pwd/etc/augmented.sbom.json.new
3030

3131
# Any notable updates to the Augmented SBOM version should be done manually after careful inspection.
32-
# Otherwise, it should be equal to the SBOM Lite version, which should normally be `1`.
32+
# Otherwise, it should be equal to the existing SBOM version.
3333
--no-update-sbom-version
3434
)
3535

36-
# First validate the SBOM Lite.
37-
podman run -it --rm -v "$(pwd):/pwd" "${silkbomb:?}" \
38-
validate --purls /pwd/etc/purls.txt --sbom-in /pwd/etc/cyclonedx.sbom.json --exclude jira
39-
4036
# Allow the timestamp to be updated in the Augmented SBOM for update purposes.
4137
podman run -it --rm -v "$(pwd):/pwd" --env 'KONDUKTO_TOKEN' "${silkbomb:?}" augment "${silkbomb_augment_flags[@]:?}"
4238

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Generate SBOM
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "master"
7+
- "releases/v*"
8+
- "debian/*"
9+
paths:
10+
- "**/CMakeLists.txt"
11+
- "**/*.cmake"
12+
push:
13+
branches:
14+
- "master"
15+
- "releases/v*"
16+
- "debian/*"
17+
paths:
18+
- "**/CMakeLists.txt"
19+
- "**/*.cmake"
20+
21+
jobs:
22+
endor_scan_and_generate_sbom:
23+
permissions:
24+
id-token: write # Required to request a json web token (JWT) for keyless authentication with Endor Labs
25+
contents: write # Required for commit
26+
pull-requests: write # Required for PR
27+
runs-on: ubuntu-latest
28+
env:
29+
PR_SCAN: ${{ github.event_name == 'pull_request' }}
30+
steps:
31+
- name: Checkout Repository
32+
uses: actions/checkout@v6
33+
with:
34+
fetch-tags: true
35+
submodules: recursive
36+
37+
- name: Configure CMake and fetch dependency sources
38+
env:
39+
BUILD_TYPE: Release
40+
BUILD: ${{github.workspace}}/build
41+
CXX_STANDARD: 17
42+
working-directory: ${{env.BUILD}}
43+
run: |
44+
cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_STANDARD=${{env.CXX_STANDARD}} -DENABLE_TESTS=ON
45+
git rm .gitignore # prevent exclusion of build/_deps from endorctl scan
46+
47+
- name: Endor Labs Scan (PR or Monitoring)
48+
uses: endorlabs/github-action@519df81de5f68536c84ae05ebb2986d0bb1d19fc # v1.1.8
49+
env:
50+
ENDOR_SCAN_EMBEDDINGS: true
51+
with:
52+
additional_args: '--languages=c --include-path="build/_deps/**"'
53+
enable_pr_comments: ${{ env.PR_SCAN }}
54+
github_token: ${{ secrets.GITHUB_TOKEN }} # Required for endorctl to write pr comments
55+
log_level: info
56+
log_verbose: false
57+
namespace: mongodb.${{github.repository_owner}}
58+
pr: ${{ env.PR_SCAN }}
59+
scan_dependencies: true
60+
scan_summary_output_type: "table"
61+
tags: github_action
62+
63+
# - name: Set up Python
64+
# if: env.PR_SCAN == false
65+
# uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
66+
# with:
67+
# python-version: "3.10"
68+
69+
- name: Install uv (push only)
70+
if: env.PR_SCAN == false
71+
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
72+
with:
73+
python-version: "3.10"
74+
activate-environment: true
75+
enable-cache: true
76+
77+
- name: Stash existing SBOM, generate new SBOM (push only)
78+
if: env.PR_SCAN == false
79+
run: |
80+
# Existing SBOM: Strip out nondeterministic SBOM fields and save to temp file
81+
jq 'del(.version, .metadata.timestamp, .metadata.tools.services[].version)' sbom.json > ${{runner.temp}}/sbom.existing.cdx.json
82+
# etc/sbom/generate_sbom.py
83+
uv run --group generate_sbom etc/sbom/generate_sbom.py --enable-github-action-token --target=branch --sbom-metadata=etc/sbom/metadata.cdx.json --save-warnings=${{runner.temp}}/warnings.txt
84+
# Generated SBOM: Strip out nondeterministic SBOM fields and save to temp file
85+
jq 'del(.version, .metadata.timestamp, .metadata.tools.services[].version)' sbom.json > ${{runner.temp}}/sbom.generated.cdx.json
86+
87+
- name: Check for SBOM changes (push only)
88+
if: env.PR_SCAN == false
89+
id: sbom_diff
90+
run: |
91+
# diff the temp SBOM files, save output to variable, supress exit code
92+
RESULT=$(diff --brief ${{runner.temp}}/sbom.existing.cdx.json ${{runner.temp}}/sbom.generated.cdx.json)
93+
# Set the output variable
94+
echo "result=$RESULT" | tee -a $GITHUB_OUTPUT
95+
96+
- name: Generate pull request content and notice message, if SBOM has changed (push only)
97+
if: env.PR_SCAN == false && steps.sbom_diff.outputs.result
98+
run: |
99+
printf "SBOM updated after commit ${{ github.sha }}.\n\n" | cat - ${{runner.temp}}/warnings.txt > ${{runner.temp}}/pr_body.txt
100+
echo "::notice title=SBOM-Diff::SBOM has changed"
101+
102+
- name: Open Pull Request, if SBOM has changed (push only)
103+
if: env.PR_SCAN == false && steps.sbom_diff.outputs.result
104+
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
105+
env:
106+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
107+
with:
108+
add-paths: sbom.json
109+
body-path: ${{runner.temp}}/pr_body.txt
110+
branch: cxx-sbom-update-${{ env.BRANCH_NAME }}
111+
commit-message: Update SBOM file(s)
112+
delete-branch: true
113+
title: CXX Update SBOM action - ${{ env.BRANCH_NAME }}

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ else()
5656
message(WARNING "Unknown compiler... recklessly proceeding without a version check")
5757
endif()
5858

59-
# Also update etc/purls.txt.
6059
set(BSON_REQUIRED_VERSION 2.1.2)
6160
set(MONGOC_REQUIRED_VERSION 2.1.2)
6261
set(MONGOC_DOWNLOAD_VERSION 2.1.2)

etc/purls.txt

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

etc/releasing.md

Lines changed: 4 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ Some release steps require one or more of the following secrets.
7575
GRS_CONFIG_USER1_USERNAME=<username>
7676
GRS_CONFIG_USER1_PASSWORD=<password>
7777
```
78-
- Snyk credentials.
79-
- Location: `~/.secrets/snyk-creds.txt`
80-
- Format:
81-
```bash
82-
SNYK_API_TOKEN=<token>
83-
```
8478
8579
## Pre-Release Steps
8680
@@ -118,22 +112,11 @@ All issues with an Impact level of "High" or greater must have a "MongoDB Final
118112
119113
All issues with an Impact level of "Medium" or greater which do not have a "MongoDB Final Status" of "Fix Committed" must document rationale for its current status in the "Notes" field.
120114
121-
### SBOM Lite
115+
### SBOM
122116
123117
Ensure the container engine (e.g. `podman` or `docker`) is authenticated with the DevProd-provided Amazon ECR instance.
124118
125-
Ensure the list of bundled dependencies in `etc/purls.txt` is up-to-date. If not, update `etc/purls.txt`.
126-
127-
If `etc/purls.txt` was updated, update the SBOM Lite document using the following command(s):
128-
129-
```bash
130-
# Ensure latest version of SilkBomb is being used.
131-
podman pull 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0
132-
133-
# Output: "... writing sbom to file"
134-
podman run -it --rm -v "$(pwd):/pwd" 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0 \
135-
update --refresh --no-update-sbom-version -p "/pwd/etc/purls.txt" -i "/pwd/etc/cyclonedx.sbom.json" -o "/pwd/etc/cyclonedx.sbom.json"
136-
```
119+
Ensure that any `CXX Update SBOM action - $BRANCH_NAME` PRs are merged for the release branch.
137120
138121
Run a patch build which executes the `sbom` task and download the "Augmented SBOM (Updated)" file as `etc/augmented.sbom.json`. Evergreen CLI may be used to schedule only the `sbom` task:
139122
@@ -154,12 +137,6 @@ Update `etc/third_party_vulnerabilities.md` with any updates to new or known vul
154137

155138
Download the "Augmented SBOM (Updated)" file from the latest EVG commit build in the `sbom` task and commit it into the repo as `etc/augmented.sbom.json` (even if the only notable change is the timestamp field).
156139

157-
### Check Snyk
158-
159-
Inspect the list of projects in the latest report for the `mongodb/mongo-cxx-driver` target in [Snyk](https://app.snyk.io/org/dev-prod/).
160-
161-
Deactivate any projects that will not be relevant in the upcoming release. Remove any projects that are not relevant to the current release.
162-
163140
### Check Jira
164141

165142
Inspect the list of tickets assigned to the version to be released on [Jira](https://jira.mongodb.com/projects/CXX?selectedItem=com.atlassian.jira.jira-projects-plugin%3Arelease-page&status=unreleased).
@@ -432,67 +409,7 @@ The new branch should be continuously tested on Evergreen. Update the "Display N
432409

433410
### Update SBOM serial number
434411

435-
Check out the release branch `releases/vX.Y`.
436-
437-
Update `etc/cyclonedx.sbom.json` with a new unique serial number for the next upcoming patch release (e.g. for `1.3.1` following the release of `1.3.0`):
438-
439-
```bash
440-
# Ensure latest version of SilkBomb is being used.
441-
podman pull 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0
442-
443-
# Output: "... writing sbom to file"
444-
podman run -it --rm -v "$(pwd):/pwd" 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0 \
445-
update --refresh --generate-new-serial-number -p "/pwd/etc/purls.txt" -i "/pwd/etc/cyclonedx.sbom.json" -o "/pwd/etc/cyclonedx.sbom.json"
446-
```
447-
448-
Update `etc/augmented.sbom.json` by running a patch build which executes the `sbom` task as described above in [SBOM Lite](#sbom-lite).
449-
450-
Commit and push these changes to the `releases/vX.Y` branch.
451-
452-
### Update Snyk
453-
454-
> [!IMPORTANT]
455-
> Run the Snyk commands in a fresh clone of the post-release repository to avoid existing build and release artifacts from affecting Snyk.
456-
457-
Checkout the new release tag.
458-
459-
Configure and build the CXX Driver (do not reuse an existing C Driver installation; use the auto-downloaded C Driver sources instead):
460-
461-
```bash
462-
cmake -S . -B build
463-
cmake --build build
464-
```
465-
466-
Then run:
467-
468-
```bash
469-
# Snyk credentials. Ask for these from a team member.
470-
. ~/.secrets/snyk-creds.txt
471-
472-
# The new release tag. Ensure this is correct!
473-
release_tag="rX.Y.Z"
474-
475-
# Authenticate with Snyk dev-prod organization.
476-
snyk auth "${SNYK_API_TOKEN:?}"
477-
478-
# Verify third party dependency sources listed in etc/purls.txt are detected by Snyk.
479-
# If not, see: https://support.snyk.io/hc/en-us/requests/new
480-
# Use --exclude=extras until CXX-3042 is resolved
481-
snyk_args=(
482-
--org=dev-prod
483-
--remote-repo-url=https://github.com/mongodb/mongo-cxx-driver/
484-
--target-reference="${release_tag:?}"
485-
--unmanaged
486-
--all-projects
487-
--exclude=extras
488-
)
489-
snyk test "${snyk_args[@]:?}" --print-deps
490-
491-
# Create a new Snyk target reference for the new release tag.
492-
snyk monitor "${snyk_args[@]:?}"
493-
```
494-
495-
Verify the new Snyk target reference is present in the [Snyk project targets list](https://app.snyk.io/org/dev-prod/projects?groupBy=targets&before&after&searchQuery=mongo-cxx-driver&sortBy=highest+severity&filters[Show]=&filters[Integrations]=cli&filters[CollectionIds]=) for `mongodb/mongo-cxx-driver`.
412+
A new SBOM serial number is automatically generated when an SBOM is generated on a new branch.
496413

497414
### Post-Release Changes
498415

@@ -512,21 +429,7 @@ For a patch release, in `etc/apidocmenu.md`, update the list of versions under "
512429

513430
In `README.md`, sync the "Driver Development Status" table with the updated table from `etc/apidocmenu.md`.
514431

515-
Update `etc/cyclonedx.sbom.json` with a new unique serial number for the next upcoming non-patch release (e.g. for `1.4.0` following the release of `1.3.0`):
516-
517-
```bash
518-
# Ensure latest version of SilkBomb is being used.
519-
podman pull 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0
520-
521-
# Output: "... writing sbom to file"
522-
podman run -it --rm -v "$(pwd):/pwd" 901841024863.dkr.ecr.us-east-1.amazonaws.com/release-infrastructure/silkbomb:2.0 \
523-
update --refresh --generate-new-serial-number -p "/pwd/etc/purls.txt" -i "/pwd/etc/cyclonedx.sbom.json" -o "/pwd/etc/cyclonedx.sbom.json"
524-
525-
git add etc/cyclonedx.sbom.json
526-
git commit -m "update SBOM serial number"
527-
```
528-
529-
Update `etc/augmented.sbom.json` by running a patch build which executes the `sbom` task as described above in [SBOM Lite](#sbom-lite).
432+
Update `etc/augmented.sbom.json` by running a patch build which executes the `sbom` task as described above in [SBOM](#sbom).
530433

531434
Commit these changes to the `post-release-changes` branch:
532435

0 commit comments

Comments
 (0)