-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ci(NODE-7025): New SBOM generation workflow on dependencies change #4807
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: main
Are you sure you want to change the base?
Changes from 6 commits
74b341c
c32122b
46659ee
e5f5aac
6908e91
856c1fd
a603292
bc0a7fc
2ab3d6d
004b014
a916462
8ec55e8
8ce4ebb
2fa4dc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: Generate SBOM | ||
| description: Generates CycloneDX SBOM using cdxgen | ||
| inputs: | ||
| output-file: | ||
| description: "Output filename for the SBOM" | ||
| required: false | ||
| default: "sbom.json" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Generate SBOM | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move the contents of this action into a standalone script? That's easier to maintain and run locally than a Github action.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd keep it as a composite actions, since it is native to github - clearer error logs and we can use success state triggers (like - if: steps.generate-sbom.outcome == 'success'), and unified across repos - close to the other repo approaches compared to script.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can keep the composite action, but instead of having multiple steps in the action, we could just call a single bash script. Would you mind making this change? |
||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| echo "Generating SBOM for 'node' project..." | ||
| npx @cyclonedx/cyclonedx-npm --package-lock-only --omit dev --output-file sbom.json --output-format json --spec-version 1.5 | ||
|
|
||
| - name: Validate SBOM | ||
| shell: bash | ||
| run: | | ||
| if [ ! -f "${{ inputs.output-file }}" ]; then | ||
| echo "Error: SBOM file not found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "SBOM file validated: ${{ inputs.output-file }}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Setup PHP SBOM | ||
|
||
| description: Sets up environment for generating SBOM in PHP projects | ||
| inputs: | ||
| working-directory: | ||
| description: "The directory where composer.json is located" | ||
| required: false | ||
| default: "." | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Setup Node.js (for cdxgen) | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install dependencies | ||
| shell: bash | ||
| run: npm ci | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Setup Node SBOM | ||
| description: Sets up environment for generating SBOM in Node.js projects | ||
| inputs: | ||
| working-directory: | ||
|
||
| description: "The directory where package.json is located" | ||
| required: false | ||
| default: "." | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Setup Node.js (for cdxgen) | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install cdxgen | ||
| shell: bash | ||
| run: npm install -g @cyclonedx/cdxgen | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,115 @@ | ||||||||||
| name: Post-Merge SBOM Update | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| push: | ||||||||||
| branches: | ||||||||||
| - main | ||||||||||
| paths: | ||||||||||
| - 'package.json' | ||||||||||
| - 'package-lock.json' | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To explicitly avoid workflow run on sbom changes.
Suggested change
|
||||||||||
| workflow_dispatch: | ||||||||||
| env: | ||||||||||
| SBOM_FILE: "sbom.json" | ||||||||||
|
||||||||||
| env: | |
| SBOM_FILE: "sbom.json" |
This won't ever change, I think, so we should be able to remove it.
Outdated
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.
| pull-requests: write |
I think we can remove this permission now that we're committing to main, right?
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.
removed
baileympearson marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
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.
| - name: Load version and package info | |
| uses: mongodb-labs/drivers-github-tools/node/get_version_info@v3 | |
| with: | |
| npm_package_name: mongodb |
This shouldn't be necessary
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.
Don't remember why I've added it, but I'll trust you and remove)
Outdated
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.
We've already run npm install above in mongodb-labs/drivers-github-tools/node/setup@v3. Is it necessary to only install from package-lock? If so, we might want to remove the call to the above action.
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.
removed
Uh oh!
There was an error while loading. Please reload this page.