Skip to content

Create SBOMs and scan for vulnerablities #20801

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

Merged
merged 7 commits into from
May 8, 2025
Merged

Conversation

corneliusludmann
Copy link
Contributor

Description

This PR improves our vulnerability detection by implementing daily scans and optimizing the scanning process.

Changes

  • Daily Vulnerability Scanning: Added scheduled workflow (midnight UTC) with Slack notifications for critical findings
  • Optimized Scanning: Created needs-vuln-scan target to focus on relevant packages only
  • Vulnerability Management: Added ignore rules with documentation for false positives
  • SBOM Integration: Enabled SBOM generation and artifact uploads
  • Dev Environment: Updated development image and related workflows

The implementation replaces direct Trivy scanning with Leeway's built-in SBOM capabilities for better build system integration. When vulnerabilities are detected, the workflow automatically notifies us on Slack.

Related Issue(s)

Fixes https://linear.app/gitpod/issue/CLC-1339/sbom-vuln-scanning-on-gitpod-iogitpod

How to test

Run the workflow with "simulate scheduled" enabled. If you remove the ignore rules, you get a Slack message like this: https://gitpod.slack.com/archives/C07270E825R/p1746699798336559

image

Preview status

gitpod:summary

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

GITPOD_TEST_TOKEN_BITBUCKET: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET }}"
GITPOD_TEST_TOKEN_BITBUCKET_SERVER: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET_SERVER }}"
GITPOD_TEST_TOKEN_BITBUCKET_SERVER_WRITE: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET_SERVER_WRITE }}"
GITPOD_TEST_TOKEN_BITBUCKET_SERVER_READ: "${{ secrets.GITPOD_TEST_TOKEN_BITBUCKET_SERVER_READ }}"
Copy link
Member

@geropl geropl May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corneliusludmann Do we really need all of these env vars? 🤔

Generally, I think producing the SBOMs should be part of the build itself - and only the scan separate - where we would not need all of these, because we effectively pull the required SBOMs from all the packages..?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also allow us to have the "scan" as separate workflow that we trigger syncronously - and get rid of the invasive && needs.configuration.outputs.is_scheduled_run != 'true' checks... 🫧

Copy link
Contributor Author

@corneliusludmann corneliusludmann May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I think producing the SBOMs should be part of the build itself - and only the scan separate - where we would not need all of these, because we effectively pull the required SBOMs from all the packages..?

In general, I agree. Actually, we generate the SBOMs during build already. However, when we want to pull the cached packages Leeway calculates the internal version (aka hash) of the packages based on the package manifest, which also includes the value of envs. When the envs are not the same, Leeway would rebuild the packages.

To be honest, I don't know which variables exactly are considered. Do you think it's worth to try it out and find the right set of variables needed for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the envs that are not needed as discussed and it works. ✔️

@@ -95,6 +96,33 @@ packages:
- ["sh", "-c", "echo \"version: ${version}\" >> versions.yaml"]
- ["sh", "-c", "dev-version-manifest--app/version-manifest >> versions.yaml"]
- ["sh", "-c", "rm -r components* dev-*"]
- name: needs-vuln-scan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, that's neat! But how do we make sure this stays complete? 🫧

Maybe not a problem for now, but rather for Flex 👍

@@ -31,6 +31,20 @@ defaultArgs:
provenance:
enabled: true
slsa: true
sbom:
enabled: true
ignoreVulnerabilities:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧡

Copy link
Contributor

github-actions bot commented May 8, 2025

⚠️ Hey reviewer! BE CAREFUL ⚠️
Review the code before opening in your Gitpod. .gitpod.yml was changed and it might be harmful.

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding "separate workflow vs same workflow": we settled with the current state, allthough it does not feel ideal from a code perspective because:

  • further leeway work required (fix ephemeral packages)
  • we don't want further delays here.

✔️

@corneliusludmann
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit e62d71d into main May 8, 2025
34 checks passed
@roboquat roboquat deleted the clu/leeway-sbom-scan branch May 8, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants