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

Fix image structure in apko SBOMs #251

Merged
merged 20 commits into from Jun 29, 2022
Merged

Conversation

puerco
Copy link
Contributor

@puerco puerco commented Jun 29, 2022

This PR implements proper image structure in the individual apko images. Both CycloneDX and SPDX have been updated to capture the structure of the images. The biggest change is when running apko publish:

  • When running apko publish and generating a Cyclonedx SBOM, the layer is now a subcomponent of a new image component.
  • When requesting an SPDX SBOM the image now has its own top level package and is related to the layer package.

It is a big refactor as the SBOM generation is now done after publishing the images and the SBOM is now attached at the end of the publish function.

Easiest to visualize it by looking at the sboms. This is before the change:

image

This is after the change:

image

There are other minor changes, each commit captures the changes as atomic as I could.

Fixes #225

puerco added 16 commits June 28, 2022 19:37
This commit moves the construction of packages describing layers and apks
to their own functions. This allows them to be reused.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
We now really use the option WantSBOM

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
In order to reuse it, we now make the tarball name deterministic
to ensure we can always know it, even if we lose it.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
This commit adds a new function to the OCI package: PostAttachSBOM
this function will now attach an sbom to an already published image.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
The options package now handles the definition and creation of
the temporary directory. This commit switched the tarball creation
paths to use the new directories handled by the options object.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
We now generate the individual image sboms after the push. We do this
to know the digest of the indidual images which need for the sboms.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
This commit renames the ImageInfo.Digest sbom option to ImageInfo.LayerDigest
which is more descriptive and less ambiguous.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
Add a new options field named ImageDigest to pass the image digest all the
way down to the sbom generators.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
This commit fixes the image sboms. When generating a full image
(ie through apko publish) apko will now wrap the layer in a new
package describing the image.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
This commit modifies the way we name the apko layer package to
name it as the layer reference in line with best practices.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
This commit fixes a panic when writing the apko build sboms where
nothing was beign built and ggcr would panic with a nil layer object.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
This commit fixes the images SBOM in cycloneDX to generate the
correct component in component structure.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
After fixing the signature of functions that generate the layers and
images, we now route the sbom paths correctly to scratch in the same
temporary directory.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
@puerco puerco requested a review from kaniini June 29, 2022 08:50
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
pkg/options/options.go Outdated Show resolved Hide resolved
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
The loops for building one and multiple images are not divergent enough
to warrant a block of their own. This commit removes the switch to
simplify the publish cli.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
kaniini
kaniini previously approved these changes Jun 29, 2022
@puerco puerco requested a review from kaniini June 29, 2022 20:04
@puerco puerco dismissed kaniini’s stale review June 29, 2022 20:34

Dismiss this review to try to retrigger CI

This commit adds a new --sbom flag to apko publish and wires it
to the options.WantSBOM field which is now working and was previously
ignored.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
@puerco
Copy link
Contributor Author

puerco commented Jun 29, 2022

GH UI seems to be acting up. Here's the mink e2e successful run: https://github.com/chainguard-dev/apko/runs/7120080211?check_suite_focus=true

@puerco puerco merged commit b54c185 into chainguard-dev:main Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SBOMs point to layer, not image
2 participants