-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add improved SBOM reports #746
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@nordeck/matrix-meetings-widget': patch | ||
'@nordeck/matrix-meetings-bot': patch | ||
--- | ||
|
||
Adds SBOM report to widget, build and release assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,10 +90,31 @@ jobs: | |
with: | ||
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'pull_request' && secrets.GH_APP_OS_APP_ID != '' }} | ||
context: ./matrix-meetings-widget/ | ||
build-contexts: | | ||
root=./ | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64,linux/s390x | ||
|
||
- name: Run Trivy to get an SBOM report of the container | ||
env: | ||
IMAGE_REF: ${{ env.DOCKER_IMAGE }}@${{ steps.dockerBuild.outputs.digest }} | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
scanners: 'license' | ||
format: 'spdx-json' | ||
output: 'matrix-meetings-widget.sbom.spdx.json' | ||
image-ref: ${{ env.IMAGE_REF }} | ||
github-pat: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload SBOM report as a build artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: matrix-meetings-widget-sbom-spdx-report | ||
path: 'matrix-meetings-widget.sbom.spdx.json' | ||
retention-days: 30 | ||
|
||
build-bot: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
@@ -182,6 +203,25 @@ jobs: | |
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64,linux/s390x | ||
|
||
- name: Run Trivy to get an SBOM report of the container | ||
env: | ||
IMAGE_REF: ${{ env.DOCKER_IMAGE }}@${{ steps.dockerBuild.outputs.digest }} | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
scanners: 'license' | ||
format: 'spdx-json' | ||
output: 'matrix-meetings-bot.sbom.spdx.json' | ||
image-ref: ${{ env.IMAGE_REF }} | ||
github-pat: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload SBOM report as a build artifcat | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: matrix-meetings-bot-sbom-spdx-report | ||
path: 'matrix-meetings-bot.sbom.spdx.json' | ||
retention-days: 30 | ||
|
||
run-changesets: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
|
@@ -254,6 +294,8 @@ jobs: | |
id: dockerBuildWidget | ||
with: | ||
context: ./matrix-meetings-widget/ | ||
build-contexts: | | ||
root=./ | ||
|
||
- name: Docker build bot | ||
uses: docker/build-push-action@v6 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
permissions: | ||
contents: read | ||
contents: write | ||
packages: write | ||
id-token: write | ||
env: | ||
|
@@ -68,6 +68,25 @@ jobs: | |
labels: ${{ steps.meta-new-tags.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64,linux/s390x | ||
|
||
- name: Run Trivy to get an SBOM report of the container | ||
env: | ||
IMAGE_REF: ${{ env.DOCKER_IMAGE }}@${{ steps.build_and_push.outputs.digest }} | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
scanners: 'license' | ||
format: 'spdx-json' | ||
output: 'sbom.spdx.json' | ||
image-ref: ${{ env.IMAGE_REF }} | ||
github-pat: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload SBOM to release assets | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.ref_name }} | ||
run: | | ||
gh release upload "$tag" sbom.spdx.json --repo="$GITHUB_REPOSITORY" | ||
|
||
- name: Sign the images with GitHub OIDC Token | ||
env: | ||
DIGEST: ${{ steps.build_and_push.outputs.digest }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
permissions: | ||
contents: read | ||
contents: write | ||
packages: write | ||
id-token: write | ||
env: | ||
|
@@ -68,6 +68,25 @@ jobs: | |
labels: ${{ steps.meta-new-tags.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64,linux/s390x | ||
|
||
- name: Run Trivy to get an SBOM report of the container | ||
env: | ||
IMAGE_REF: ${{ env.DOCKER_IMAGE }}@${{ steps.build_and_push.outputs.digest }} | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
scanners: 'license' | ||
format: 'spdx-json' | ||
output: 'sbom.spdx.json' | ||
image-ref: ${{ env.IMAGE_REF }} | ||
github-pat: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload SBOM to release assets | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.ref_name }} | ||
run: | | ||
gh release upload "$tag" sbom.spdx.json --repo="$GITHUB_REPOSITORY" | ||
|
||
- name: Sign the images with GitHub OIDC Token | ||
env: | ||
DIGEST: ${{ steps.build_and_push.outputs.digest }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
FROM node:20-bookworm-slim AS node_modules | ||
FROM aquasec/trivy:latest AS scanner | ||
|
||
# Copy yarn.lock to run SBOM scan | ||
COPY yarn.lock /tmp | ||
RUN trivy fs --format spdx-json --scanners "license" /tmp/yarn.lock > /tmp/sbom.spdx.json | ||
|
||
FROM node:20-bookworm-slim AS builder | ||
|
||
WORKDIR /build | ||
|
||
COPY package.json yarn.lock ./ | ||
COPY matrix-meetings-bot/package.json ./matrix-meetings-bot/ | ||
COPY packages/calendar/package.json ./packages/calendar/package.json | ||
COPY packages/calendar/lib ./packages/calendar/lib | ||
RUN yarn install --production --frozen-lockfile --network-timeout 1000000 | ||
|
||
# Runtime image | ||
FROM node:20-bookworm-slim | ||
|
||
ENV NODE_ENV=production | ||
WORKDIR /app | ||
|
||
# update npm to address CVE-2024-21538 | ||
RUN npm install -g [email protected] | ||
|
||
# Add SBOM to the public folder | ||
COPY --from=scanner /tmp/sbom.spdx.json /usr/local/share/doc/matrix-meetings-bot.sbom.spdx.json | ||
|
||
RUN set -x\ | ||
&& mkdir /app/storage \ | ||
&& chown -R 101:0 /app/storage \ | ||
&& chmod -R g+w /app/storage | ||
USER 101 | ||
COPY --from=node_modules /build/node_modules/ ./node_modules | ||
COPY --from=node_modules /build/packages/calendar/ ./packages/calendar/ | ||
COPY --from=builder /build/node_modules/ ./node_modules | ||
COPY --from=builder /build/packages/calendar/ ./packages/calendar/ | ||
COPY matrix-meetings-bot/conf ./conf | ||
COPY matrix-meetings-bot/lib ./lib | ||
CMD ["node", "./lib/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could not see these in artifacts similar to other widgets. Am I looking wrong somehow?
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.
you're right, they are not listed there. But they are being uploaded and the logs reference the uploaded file. I'll check if we need to adjust the artifact path because of having two builds in the same workflow.
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.
can you check again? It might have been a temporary github issue, as they are now listed: