Skip to content
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

Integrate Native Image SBOM with GitHub's Dependency Submission API #119

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

rudsberg
Copy link
Contributor

@rudsberg rudsberg commented Dec 4, 2024

Overview

This PR adds support to automatically generate a highly accurate SBOM with Native Image and submit it to GitHub's dependency submission API. That enables a simple integration with all the powerful security tooling that Github provides:

The feature is activated with the option native-image-enable-sbom. It requires contents: write permission and for the Dependency Graph feature to be activated (on by default for public repositories). This feature is supported for GraalVM for JDK 24 or above. It cannot be used for earlier versions since the purl SBOM field, which the GitHub API requires, is only available in the upcoming JDK 24 release.

Approach and Testing

The high-level approach for the implementation is the following:

  1. run in main.ts calls setUpSBOMSupport which appends --enable-sbom=export to NATIVE_IMAGE_OPTIONS. Effectively, this instructs any subsequent invocation of native-image to generate an SBOM.
  2. run in cleanup.ts calls processSBOM which finds the SBOM, maps the content to the format the GitHub API expects, and submits it to the API.

The feature is tested with a mix of unit and integration tests:

  • sbom.test.ts runs unit and integration tests. The GitHub API is mocked.
  • test.yml is extended with a new job sbom-test which builds a maven project and asserts that an SBOM is created and verifies its contents.

Example

Consider the test project that the job sbom-test uses which defines one Java class with a dependency on org.json. After the job has executed, the GitHub dashboard is populated with vulnerability alerts under Security/Dependabot and the Dependency Graph under Insights/Dependency graph. Here is how the Security/Dependabot page looks like:

dependabot_alerts

A specific vulnerability:

dependabot_vulnerability

The Insights/Dependency graph includes the org.json component which was part of the SBOM and the dependencies picked up automatically from the manifest files:

dependency_graph

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 4, 2024
@rudsberg
Copy link
Contributor Author

rudsberg commented Dec 4, 2024

There is one failing test which is not related to this PR:
build-test / GraalVM (17.0.13, graalvm, ubuntu-latest, true).

Copy link
Member

@fniephaus fniephaus left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @rudsberg! Looks very good already. Left a couple of comments and suggestions.

__tests__/sbom/main-test-app/pom.xml Outdated Show resolved Hide resolved
__tests__/sbom/main-test-app/pom.xml Outdated Show resolved Hide resolved
__tests__/sbom/main-test-app/verify-sbom.sh Outdated Show resolved Hide resolved
__tests__/sbom/main-test-app/verify-sbom.sh Outdated Show resolved Hide resolved
__tests__/sbom/main-test-app/pom.xml Outdated Show resolved Hide resolved
src/features/sbom.ts Show resolved Hide resolved
src/features/sbom.ts Show resolved Hide resolved
src/features/sbom.ts Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
@rudsberg rudsberg requested a review from fniephaus January 6, 2025 11:57
@fniephaus fniephaus self-assigned this Jan 20, 2025
fniephaus
fniephaus previously approved these changes Jan 20, 2025
Copy link
Member

@fniephaus fniephaus left a comment

Choose a reason for hiding this comment

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

LGTM

@fniephaus fniephaus merged commit 7b74bd8 into graalvm:main Jan 21, 2025
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants