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

New SBOM generation process #487

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

flavio
Copy link
Member

@flavio flavio commented Jul 25, 2023

Use syft to produce bill or materials of the container image contents and the application itself.

Ensure each architecture-specific build has its own SBOM, signed and attached to the specific image.

Also, attach to the GH release the SBOM of each container image being built.

GH actions

A preview of the results produced by the this new approach can be found here:

  • Push against main: GH run. The run now has a sbom artifact, this contains the spdx files and all their signatures
  • New tag:
    • GH run. The run failed because it couldn't perform the last release step: triggering the update of helm charts; this fine, since the tag happened inside of a fork
    • GH release. We now have assets for both the arm64 and amd64 builds

Container images

Prior to this commit the SBOM was only generated for the x86_64 platform and was attached to the multi-architecture container image index manifest.

Prior to this change the SBOM was attached to the image index manifest:

cosign download sbom --output-file sbom.spdx ghcr.io/kubewarden/kubewarden-controller:v1.6.0
WARNING: Downloading SBOMs this way does not ensure its authenticity. If you want to ensure a tamper-proof SBOM, download it using 'cosign download attestation <image uri>' or verify its signature using 'cosign verify --key <key path> --attachment sbom <image uri>'.
Found SBOM of media type: text/spdx

After this PR the SBOM is no longer attached to the image index:

WARNING: Downloading SBOMs this way does not ensure its authenticity. If you want to ensure a tamper-proof SBOM, download it using 'cosign download attestation <image uri>' or verify its signature using 'cosign verify --key <key path> --attachment sbom <image uri>'.

This multiarch image does not have an SBOM attached at the index level.
Try using --platform with one of the following architectures:
linux/amd64, linux/arm64, unknown/unknown, unknown/unknown

Error: no SBOM found attached to image index
main.go:74: error during command execution: no SBOM found attached to image index

Instead, they are attached to the actual container images.

This is the amd64 SBOM:

cosign download sbom --output-file amd64-sbom.spdx ghcr.io/flavio/kubewarden-controller@$(crane digest --platform linux/amd64 ghcr.io/flavio/kubewarden-controller:v1.7.1)
WARNING: Downloading SBOMs this way does not ensure its authenticity. If you want to ensure a tamper-proof SBOM, download it using 'cosign download attestation <image uri>' or verify its signature using 'cosign verify --key <key path> --attachment sbom <image uri>'.
Found SBOM of media type: text/spdx

While this one is the arm64 one:

cosign download sbom --output-file arm64-sbom.spdx ghcr.io/flavio/kubewarden-controller@$(crane digest --platform linux/arm64 ghcr.io/flavio/kubewarden-controller:v1.7.1)
WARNING: Downloading SBOMs this way does not ensure its authenticity. If you want to ensure a tamper-proof SBOM, download it using 'cosign download attestation <image uri>' or verify its signature using 'cosign verify --key <key path> --attachment sbom <image uri>'.
Found SBOM of media type: text/spdx

Use syft to produce bill or materials of the container image and the
application itself.

Ensure each architecture-specific build has its own SBOM, signed and
attached to the specific image.

Also, attach to the GH release the SBOM of each container image being
built.

Prior to this commit the SBOM was only generated for the x86_64 platform
and was attached to the multi-architecture container image index
manifest.

Signed-off-by: Flavio Castelli <[email protected]>
@flavio flavio requested a review from a team as a code owner July 25, 2023 10:12
@flavio flavio requested a review from viccuad July 25, 2023 10:13
@flavio
Copy link
Member Author

flavio commented Jul 25, 2023

@viccuad iterating over the controller was faster than doing that against policy-server. Once merged I'll propagate these changes made to the GH workflows to the new build proposal I created against the policy-server repo

.github/workflows/sbom.yml Outdated Show resolved Hide resolved
Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

Looks good, I like it! Quite an improvement!

'kubewarden-controller-sbom-arm64.spdx',
'kubewarden-controller-sbom-arm64.spdx.cert',
'kubewarden-controller-sbom-arm64.spdx.sig',
"CRDS.tar.gz"]
Copy link
Member

Choose a reason for hiding this comment

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

(opening thread here randomly)

Unrelated to this PR, but,
What happens if the release fails on triggering the helm-charts repo?
We can retrigger the job, without rebuilding and overwriting the release, correct?
I wouldn't like to release something and later overwrite the same release version with different artifacts.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could try to rerun only the failed job, that's an option. Otherwise I fear we will have to either manually create the PR that updates the helm chart or tag a new patch release

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy just re-triggering the job that is in your fork as it is, to see what happens.

Signed-off-by: Flavio Castelli <[email protected]>
@flavio
Copy link
Member Author

flavio commented Jul 25, 2023

@viccuad please take a look at the last commit I just pushed. It addresses your feedback, plus it brings back image signing

Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the changes!

@flavio flavio merged commit e6196ff into kubewarden:main Jul 25, 2023
7 checks passed
@flavio flavio deleted the new-sbom-generation-process branch July 25, 2023 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants