Skip to content

Commit 1c15f9e

Browse files
authored
chore: Onboard to Silkbomb to generate SSDLC reports, SBOM and generate augmented SBOM on demand (#620)
1 parent 759a452 commit 1c15f9e

File tree

11 files changed

+270
-0
lines changed

11 files changed

+270
-0
lines changed

.github/workflows/autorelease.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ on:
1010
jobs:
1111
release:
1212
runs-on: ubuntu-latest
13+
outputs:
14+
release_tag: ${{ steps.set_tag.outputs.release_tag }}
1315
steps:
1416
- name: Checkout
1517
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1618
- name: Release env
19+
id: set_tag
1720
working-directory: ./tools
1821
run: |
1922
./releaser/scripts/setghenv.sh
23+
echo "release_tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT
2024
- name: Create Release
2125
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
2226
with:
@@ -29,3 +33,50 @@ jobs:
2933
LATEST_SDK_RELEASE=$(echo "${LATEST_SDK_TAG}" | cut -d '.' -f 1)
3034
echo "tag: ${LATEST_SDK_TAG}, release: ${LATEST_SDK_RELEASE}"
3135
curl -sSfL "https://proxy.golang.org/go.mongodb.org/atlas-sdk/${LATEST_SDK_RELEASE}/@v/${LATEST_SDK_TAG}.info"
36+
compliance:
37+
needs: release
38+
runs-on: ubuntu-latest
39+
env:
40+
SILKBOMB_IMG: ${{ vars.SILKBOMB_IMG }}
41+
RELEASE_TAG: ${{ needs.release.outputs.release_tag }}
42+
steps:
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
44+
with:
45+
ref: ${{ env.RELEASE_TAG }}
46+
- name: Generate PURLs and SBOM
47+
run: make gen-purls gen-sbom
48+
- name: Upload SBOM to Kondukto
49+
run: make upload-sbom
50+
env:
51+
KONDUKTO_TOKEN: ${{ secrets.KONDUKTO_TOKEN }}
52+
KONDUKTO_REPO: ${{ vars.KONDUKTO_REPO }}
53+
KONDUKTO_BRANCH_PREFIX: ${{ vars.KONDUKTO_BRANCH_PREFIX }}
54+
- name: Upload SBOM as release artifact
55+
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
56+
with:
57+
files: compliance/sbom.json
58+
tag_name: ${{ env.RELEASE_TAG }}
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
generate-ssdlc-report:
62+
needs: compliance
63+
runs-on: ubuntu-latest
64+
env:
65+
RELEASE_TAG: ${{ needs.release.outputs.release_tag }}
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
69+
- uses: ./.github/templates/run-script-and-commit
70+
with:
71+
script_call: |
72+
TAG="${{ env.RELEASE_TAG }}"
73+
VERSION="${TAG#v}"
74+
AUTHOR="${{ github.actor }}"
75+
export AUTHOR VERSION
76+
./scripts/compliance/gen-ssdlc-report.sh
77+
file_to_commit: 'compliance/v*/ssdlc-compliance-*.md'
78+
commit_message: "chore: Update SSDLC report for ${{ env.RELEASE_TAG }}"
79+
apix_bot_pat: ${{ secrets.APIX_BOT_PAT }}
80+
remote: https://svc-apix-bot:${{ secrets.APIX_BOT_PAT }}@github.com/${{ github.repository }}
81+
gpg_private_key: ${{ secrets.APIX_BOT_GPG_PRIVATE_KEY }}
82+
passphrase: ${{ secrets.APIX_BOT_PASSPHRASE }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Augment SBOM
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: "Release version (e.g. 3.12.1)"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
jobs:
16+
augment-sbom:
17+
runs-on: ubuntu-latest
18+
env:
19+
KONDUKTO_TOKEN: ${{ secrets.KONDUKTO_TOKEN }}
20+
KONDUKTO_REPO: ${{ vars.KONDUKTO_REPO }}
21+
KONDUKTO_BRANCH_PREFIX: ${{ vars.KONDUKTO_BRANCH_PREFIX }}
22+
SILKBOMB_IMG: ${{ vars.SILKBOMB_IMG }}
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
25+
26+
- name: Get current date
27+
id: date
28+
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
29+
30+
- name: Augment SBOM with Kondukto
31+
env:
32+
RELEASE_VERSION: ${{ inputs.release_version }}
33+
run: ./scripts/compliance/augment-sbom.sh
34+
- name: Generate SSDLC report
35+
env:
36+
AUTHOR: ${{ github.actor }}
37+
VERSION: ${{ inputs.release_version }}
38+
AUGMENTED_REPORT: "true"
39+
run: ./scripts/compliance/gen-ssdlc-report.sh
40+
41+
- name: Upload augmented SBOM as artifact
42+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
43+
with:
44+
name: augmented_sbom_and_ssdlc_report
45+
path: |
46+
compliance/augmented-sbom-v${{ inputs.release_version }}-${{ steps.date.outputs.date }}.json
47+
compliance/ssdlc-compliance-${{ inputs.release_version }}-${{ steps.date.outputs.date }}.md
48+
if-no-files-found: error

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,19 @@ We recommend to create separate PR containing only documentation files each time
134134
Documentation team will be assigned as reviewer automatically and will help with review of the PR.
135135

136136

137+
## Third Party Dependencies and Vulnerability Scanning
137138

139+
We scan our dependencies for vulnerabilities and incompatible licenses using [Snyk](https://snyk.io/).
140+
To run Snyk locally please follow their [CLI reference](https://support.snyk.io/hc/en-us/articles/360003812458-Getting-started-with-the-CLI).
138141

142+
We also use Kondukto to scan for third-party dependency vulnerabilities. Kondukto creates tickets in MongoDB's issue tracking system for any vulnerabilities found.
143+
144+
### SBOM and Compliance
145+
We generate Software Bill of Materials (SBOM) files for each release as part of MongoDB's SSDLC initiative. SBOM Lite files are automatically generated and included as release artifacts. Compliance reports are generated after each release and stored in the compliance/<release-version> directory.
146+
147+
Augmented SBOMs can be generated on customer request for any released version. This can only be done by MongoDB employees as it requires access to our GitHub workflow.
148+
149+
### Papertrail Integration
150+
All releases are recorded using a MongoDB-internal application called Papertrail. This records various pieces of information about releases, including the date and time of the release, who triggered the release (by pushing to Evergreen), and a checksum of each release file.
151+
152+
This is done automatically as part of the release.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,19 @@ openapi-pipeline: install-goimports
7272
gen-docs:
7373
$(MAKE) -C tools generate_docs
7474
./scripts/toc.sh
75+
76+
.PHONY: gen-purls
77+
gen-purls:
78+
./scripts/compliance/gen-purls.sh
79+
80+
.PHONY: gen-sbom
81+
gen-sbom:
82+
./scripts/compliance/gen-sbom.sh
83+
84+
.PHONY: gen-ssdlc-report
85+
gen-ssdlc-report:
86+
./scripts/compliance/gen-ssdlc-report.sh
87+
88+
.PHONY: upload-sbom
89+
upload-sbom:
90+
./scripts/compliance/upload-sbom.sh

scripts/compliance/augment-sbom.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
: "${RELEASE_VERSION:?RELEASE_VERSION environment variable not set}"
5+
DATE=$(date +'%Y-%m-%d')
6+
7+
echo "Augmenting SBOM..."
8+
docker run \
9+
--pull=always \
10+
--platform="linux/amd64" \
11+
--rm \
12+
-v "${PWD}:/pwd" \
13+
-e KONDUKTO_TOKEN \
14+
"$SILKBOMB_IMG" \
15+
augment \
16+
--sbom-in "/pwd/compliance/sbom.json" \
17+
--repo "$KONDUKTO_REPO" \
18+
--branch "$KONDUKTO_BRANCH_PREFIX-linux-arm64" \
19+
--sbom-out "/pwd/compliance/augmented-sbom-v${RELEASE_VERSION}-${DATE}.json"

scripts/compliance/extract-purls.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ "$#" -ne 2 ]; then
5+
echo "Usage: $0 <binary_path> <output_file>"
6+
exit 1
7+
fi
8+
9+
BINARY_PATH="$1"
10+
OUTPUT_FILE="$2"
11+
12+
go version -m "$BINARY_PATH" | \
13+
awk '$1 == "dep" || $1 == "=>" { print "pkg:golang/" $2 "@" $3 }' | \
14+
LC_ALL=C sort > "$OUTPUT_FILE"

scripts/compliance/gen-purls.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
OUT_DIR="compliance"
5+
PURL_FILE="${OUT_DIR}/purls.txt"
6+
mkdir -p "$OUT_DIR"
7+
8+
# Generate purls for all dependencies (including indirect)
9+
echo "==> Generating purls from go.mod dependencies"
10+
go list -m all | tail -n +2 | awk '{print "pkg:golang/" $1 "@" $2}' | LC_ALL=C sort | uniq > "$PURL_FILE"
11+
12+
echo "PURLs written to $PURL_FILE"

scripts/compliance/gen-sbom.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "Generating SBOM..."
5+
docker run --rm \
6+
-v "$PWD:/pwd" \
7+
"$SILKBOMB_IMG" \
8+
update \
9+
--purls /pwd/compliance/purls.txt \
10+
--sbom-out /pwd/compliance/sbom.json
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
release_date=${DATE:-$(date -u '+%Y-%m-%d')}
5+
6+
export DATE="${release_date}"
7+
8+
if [ -z "${AUTHOR:-}" ]; then
9+
AUTHOR=$(git config user.name)
10+
fi
11+
12+
if [ -z "${VERSION:-}" ]; then
13+
VERSION=$(git tag --list 'v*' --sort=-taggerdate | head -1 | cut -d 'v' -f 2)
14+
fi
15+
16+
if [ "${AUGMENTED_REPORT:-false}" = "true" ]; then
17+
target_dir="."
18+
file_name="ssdlc-compliance-${VERSION}-${DATE}.md"
19+
SBOM_TEXT=" - See Augmented SBOM manifests (CycloneDX in JSON format):
20+
- This file has been provided along with this report under the name 'linux_amd64_augmented_sbom_v${VERSION}.json'
21+
- Please note that this file was generated on ${DATE} and may not reflect the latest security information of all third party dependencies."
22+
23+
else # If not augmented, generate the standard report
24+
target_dir="compliance/v${VERSION}"
25+
file_name="ssdlc-compliance-${VERSION}.md"
26+
SBOM_TEXT=" - See SBOM Lite manifests (CycloneDX in JSON format):
27+
- https://github.com/mongodb/atlas-cli-plugin-terraform/releases/download/v${VERSION}/sbom.json"
28+
# Ensure atlas-cli-plugin-terraform version directory exists
29+
mkdir -p "${target_dir}"
30+
fi
31+
32+
export AUTHOR
33+
export VERSION
34+
export SBOM_TEXT
35+
36+
echo "Generating SSDLC report for Atlas CLI plugin for Terraform's MongoDB Atlas Provider version ${VERSION}, author ${AUTHOR} and release date ${DATE}..."
37+
38+
envsubst < templates/ssdlc-compliance.template.md \
39+
> "${target_dir}/${file_name}"
40+
41+
echo "SSDLC compliance report ready. Files in ${target_dir}/:"
42+
ls -l "${target_dir}/"
43+
44+
echo "Printing the generated report:"
45+
cat "${target_dir}/${file_name}"

scripts/compliance/upload-sbom.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "Uploading SBOMs..."
5+
docker run --rm \
6+
-v "$PWD:/pwd" \
7+
-e KONDUKTO_TOKEN \
8+
"$SILKBOMB_IMG" \
9+
upload \
10+
--sbom-in /pwd/compliance/sbom.json \
11+
--repo "$KONDUKTO_REPO" \
12+
--branch "$KONDUKTO_BRANCH_PREFIX"

0 commit comments

Comments
 (0)