-
Notifications
You must be signed in to change notification settings - Fork 71
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
SBOM layer support #278
Open
RealHarshThakur
wants to merge
1
commit into
buildpacks:main
Choose a base branch
from
RealHarshThakur:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
SBOM layer support #278
Changes from all commits
Commits
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,106 @@ | ||
# Meta | ||
[meta]: #meta | ||
- Name: SBOM attachment - OCI v1.1 spec | ||
- Start Date: 2023-02-24 | ||
- Author(s): harsh | ||
- Status: draft | ||
- RFC Pull Request: wip | ||
- CNB Pull Request: n/a | ||
- CNB Issue: n/a | ||
- Supersedes: n/a | ||
|
||
# Summary | ||
[summary]: #summary | ||
|
||
Currently, SBOM(s) in buildpack produced images don't have them attached to the resulting OCI artifact as a dedicated layer with IANA-registered media types. OCI v1.1 specification recommends to do so as it would make [other tools](https://github.com/sigstore/cosign/blob/main/specs/SBOM_SPEC.md) in the ecosystem interoperable with each other. | ||
|
||
# Definitions | ||
[definitions]: #definitions | ||
|
||
|
||
- [SBOM(software bill of materials)](https://www.cisa.gov/sbom) -- A SBOM is a nested inventory, a list of ingredients that make up software components | ||
- [OCI Artifact](https://github.com/opencontainers/artifacts/blob/main/definitions-terms.md#media-type) -- Any blob of data that can be stored in an OCI registry. From the spec: | ||
> An artifact has a type, which has a collection of layers. The Artifact is defined as unique by its `manifest.config.mediaType`. Layers are defined by their `layer.config.mediaType`. | ||
|
||
# Motivation | ||
[motivation]: #motivation | ||
|
||
As an end user, it would be easy to use a single tool to interact with OCI artifacts for SBOM information- to enable that, the build tools in the ecosystem would need to comply to the specification. | ||
|
||
# What it is | ||
[what-it-is]: #what-it-is | ||
|
||
This change allows an end user to view the OCI manifest of buildpack produced image and find a dedicated SBOM layer within it. For example, | ||
|
||
|
||
```json | ||
{ | ||
"schemaVersion": 2, | ||
"mediaType": "application/vnd.oci.image.manifest.v1+json", | ||
"config": { | ||
"mediaType": "application/vnd.dev.cosign.artifact.sbom.v1+json", | ||
"size": 669, | ||
"digest": "sha256:b5af1565ca06a6163b8712cbfa653a712774280856639bc1eee5a1ca7ba99b7d" | ||
}, | ||
"layers": [ | ||
{ | ||
"mediaType": "application/vnd.syft+json", | ||
"size": 621, | ||
"digest": "sha256:4b6da9488c8c58b0cf2a6ab17ec6c1f61c253c72fae89058e0f36a9d2b56ff38" | ||
}, | ||
{ | ||
"mediaType": "text/spdx+json", | ||
"size": 3154, | ||
"digest": "sha256:ccd7ff261d5506b9345c0b066b903bd0ef2d8ccd9f833ce738773d19c57f517e" | ||
}, | ||
} | ||
``` | ||
|
||
This will also tools like [Cosign](https://github.com/sigstore/cosign) that are not maintained by Buildpack community to seamlessly support SBOM interaction with it. | ||
|
||
# How it Works | ||
[how-it-works]: #how-it-works | ||
|
||
|
||
To seamlessly integrated with existing builder-images, it might be best to have the [lifecycle binary](https://github.com/buildpacks/lifecycle) add the SBOM layers to the resulting image in the Exporter phase. Lifecycle has access to the layers directory. At a high level, it has to : | ||
* Find the SBOMs produced in the layers directory | ||
* Attach SBOMs to the image before publishing it | ||
|
||
Here's a [simple Go](https://github.com/RealHarshThakur/attach-sbom) program that does that by: | ||
* Accpeting a buildpack produced image | ||
* Layers directory (downloaded through `pack sbom download`) | ||
|
||
|
||
From implementation perspective, this will have to be split up into [imgutil](https://github.com/buildpacks/imgutil/blob/main/image.go#L36) package which lifecycle uses in Export phase. | ||
|
||
|
||
# Migration | ||
[migration]: #migration | ||
|
||
N/a | ||
|
||
|
||
# Drawbacks | ||
[drawbacks]: #drawbacks | ||
|
||
None that I can think of | ||
|
||
# Alternatives | ||
[alternatives]: #alternatives | ||
|
||
N/a | ||
|
||
# Prior Art | ||
[prior-art]: #prior-art | ||
|
||
Similar work has been done already in [Cosign](https://github.com/sigstore/cosign/pull/2684) | ||
|
||
# Unresolved Questions | ||
[unresolved-questions]: #unresolved-questions | ||
N/a | ||
|
||
# Spec. Changes (OPTIONAL) | ||
[spec-changes]: #spec-changes | ||
|
||
This doesn't break the existing spec nor does it require builder imaages to add any new features. | ||
|
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.
How would
pack sbom download mytag
work if we adopt this RFC?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.
OCI artifact will have the SBOM embedded during build time. CLI can query the container registry for it filtering by artifact type.
https://github.com/opencontainers/distribution-spec/blob/main/spec.md#api
To remain backward-compaitable, I guess CLI will have to fallback to extracting the layers if it doesn't find any.