-
Notifications
You must be signed in to change notification settings - Fork 915
GODRIVER-3599 Add task and script to generate CycloneDX SBOM #2154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
GODRIVER-3599 Add task and script to generate CycloneDX SBOM #2154
Conversation
API Change ReportNo changes found! |
The GODRIVER SBOM (sbom.json) does not contain the direct and transitive dependencies defined in go.mod. Added code to generate a CycloneDX SBOM in order to better meet NITA Minimum Elements for Software Bill of Materials, OWASP Software Component Verification Standard (SCVS) Level 1, as well as include the necessary component identifiers for vulnerability discovery and VEX responses. Added a task, etc/script, and pre-commit hook for generating a CycloneDX SBOM using a pinned version of the cyclonedx-gomod tool. The SBOM includes the aggregate of modules required by packages in the mongo-go-driver library, excluding examples, tests and test packages. The task (generate-sbom) is added to the default tasks and will run only when go.mod is newer than sbom.cdx.json. The pre-commit hook (sbom-currency) ensures that if go.mod is staged for commit, that an updated sbom.json is also staged. Future TODO: Add libmongocrypt as an optional component once the libmongocrypt SBOM is updated with newer automation
7c63b31
to
a0af51a
Compare
- id: sbom-currency | ||
name: sbom-currency | ||
language: system | ||
types: [json] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hook won't run if a commit changes go.mod
. Is that intentional?
summary: | | ||
Generate a CycloneDX SBOM with the cyclonedx-gomod 'mod' subcommand | ||
The SBOM includes the aggregate of modules required by packages in the mongo-go-driver library, excluding examples, tests and test packages. | ||
Task will run only when go.mod is newer than sbom.cdx.json. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be sbom.json and not sbom.cdx.json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch. That is a typo leftover from when I was naming the file sbom.cdx.json
. Will fix.
|
||
if ! $CHECK_CURRENCY; then | ||
# The cyclonedx-gomod 'mod' subcommand is used to generate a CycloneDX SBOM with GOWORK=off to exclude example/test code. | ||
# TODO: Add libmongocrypt as an optional component via a merge once the libmongocrypt SBOM is updated with newer automation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a followup GODRIVER ticket?
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
done | ||
#shift $((OPTIND - 1)) | ||
|
||
if ! $CHECK_CURRENCY; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this script fail under certain conditions? For example, if it's being (1) called from the Evergreen CI and (2) calling results in a change to sbom.json? In such cases, I would expect the "Static Analysis" task to fail.
Running directly:
EXPECT_ERROR=1 bash etc/generate-sbon.sh # -> if sbom.json updates, exit 1
In the associated task:
- name: generate-sbom
tags: ["ssdlc", "static-analysis"]
commands:
- command: subprocess.exec
params:
binary: bash
env:
EXPECT_ERROR: 1
args: [*task-runner, generate-sbom]
GODRIVER-3599
Summary
Added a task, etc/script, and pre-commit hook for generating a CycloneDX SBOM using a pinned version of the
cyclonedx-gomod
tool. The SBOM includes the aggregate of modules required by packages in the mongo-go-driver library, excluding examples, tests and test packages (i.e., only components used at runtime).The task (
generate-sbom
) is added to the default tasks and will run only whengo.mod
is newer thansbom.json
.The pre-commit hook (
sbom-currency
) ensures that ifgo.mod
is staged for commit, that an updatedsbom.json
is also staged.Future TODO: Add
libmongocrypt
as an optional component once thelibmongocrypt
SBOM is updated with newer automationBackground & Motivation
The GODRIVER SBOM (
sbom.json
) does not contain the direct and transitive dependencies defined in go.mod. Added code to generate a CycloneDX SBOM in order to better meet NITA Minimum Elements for Software Bill of Materials, OWASP Software Component Verification Standard (SCVS) Level 1, as well as include the necessary component identifiers for vulnerability discovery and VEX responses.