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

generate SBOM both SPDX and Cyclone DX formats based for container images and attach em by using cosign attach #669

Open
developer-guy opened this issue Jan 5, 2022 · 17 comments
Labels

Comments

@developer-guy
Copy link
Contributor

We (w/@Dentrax) thought that Syft is a popular tool to allows us to generate SBOMs easily and quickly. Even GoReleaser project using syft under the hood to generate an SBOM. We have recently added cosign support to sign and verify container images while building/pushing and pulling in nerdctl. So, cosign has SBOM spec defined to let people attach SBOM (both SPDX and Cyclone DX formats) files to container images by using cosign attach command.

So, let's add that support to the nerdctl CLI too. We can generate an SBOM file while pushing the container image, then attach the SBOM file to it.

WDYT?

cc: @dlorenc @AkihiroSuda @luhring @wagoodman

@AkihiroSuda
Copy link
Member

How will the CLI look like?

@developer-guy
Copy link
Contributor Author

developer-guy commented Jan 5, 2022

IMHO, an --sbom flag should cover all the things and can accept both spdx, and cyclonedx as a value. So, the command will look like the following:

$ nerdctl image push -t <foo> --sbom <spdx|cyclonedx> .

AFAIK, Syft can only generate an SBOM file based on SPDX format, so we can use another tool cylonedx-go to generate an SBOM file based on Cyclone DX format.

Syft can generate an SBOM file for both formats.

@developer-guy
Copy link
Contributor Author

We don't have to use syft as an executable way, I've recently asked @wagoodman to give us an example of how to use syft as a Go module, thanks to him, he created a gist for it.

👉 https://gist.github.com/wagoodman/57ed59a6d57600c23913071b8470175b

@developer-guy
Copy link
Contributor Author

kinly ping @AkihiroSuda @Dentrax

@AkihiroSuda
Copy link
Member

Probably the CLI and the output format should be compatible with https://github.com/docker/sbom-cli-plugin

@developer-guy
Copy link
Contributor Author

it will be because they use Syft too under the hood

@developer-guy
Copy link
Contributor Author

There are two ways of developing this feature. The first is executing the Syft binary as we did while implementing the signing feature by performing the cosign binary. The latter depends on Syft packages by adding it to the go.mod file. Syft binary is about 60MB in size, btw.

@developer-guy
Copy link
Contributor Author

Kindly ping @AkihiroSuda

@AkihiroSuda
Copy link
Member

Executing a separate syft binary is preferable

@Dentrax
Copy link
Contributor

Dentrax commented Jun 13, 2022

If we maintain separate syft executable internally, I think it would be better to start related flags with --syft- prefix.

$ nerdctl image push -t <IMAGE> --sbom-format <SPDX|CYCLONEDX> --sbom-attach --sbom-output /path/to/file

User may want to either attach SBOM directly to upstream or export the local disk. All flags are optional.

Cross ref: anchore/syft#592

cc @developer-guy @luhring

@developer-guy
Copy link
Contributor Author

Syft is also capable of attaching an SBOM result1 in the form of in-toto attestations2 with its new command called attest3, and this command also signs the SBOM result and then uploads it to the transparency log. We might also prefer to support this behavior.

Footnotes

  1. https://anchore.com/sbom/creating-sbom-attestations-using-syft-and-sigstore/

  2. https://github.com/in-toto/attestation

  3. https://github.com/anchore/syft/issues/835

@developer-guy
Copy link
Contributor Author

kindly ping sir @AkihiroSuda

@AkihiroSuda
Copy link
Member

kindly ping sir @AkihiroSuda

#669 (comment)
#669 (comment)

@RealHarshThakur
Copy link

RealHarshThakur commented Sep 7, 2023

Looks like there's been some progress in this aspect with pluggable SBOM generators: https://github.com/docker/buildkit-syft-scanner/tree/master . Docker CLI relies on a flag to attach the SBOM.
I think making the image customizable would allow nerdctl to help with forward compatibility as I'm sure there'll be other adapters in the future. Similarly, we can have SLSA provenance enabled(maybe even by default with mode=min?).
More than happy to contribute to this :)

@AkihiroSuda
Copy link
Member

Looks like there's been some progress in this aspect with pluggable SBOM generators: https://github.com/docker/buildkit-syft-scanner/tree/master . Docker CLI relies on a flag to attach the SBOM. I think making the image customizable would allow nerdctl to help with forward compatibility as I'm sure there'll be other adapters in the future. Similarly, we can have SLSA provenance enabled(maybe even by default with mode=min?). More than happy to contribute to this :)

👍
How will the CLI look like?

@RealHarshThakur
Copy link

The current docker command is this, so a flag: build --sbom=true. I think we can remain docker-like in that aspect and have an environment variable that determines which SBOM plugin generator image users would like to use to generate SBOMs, default to the one Docker uses for now.

@AkihiroSuda
Copy link
Member

The current docker command is this, so a flag: build --sbom=true. I think we can remain docker-like in that aspect and have an environment variable that determines which SBOM plugin generator image users would like to use to generate SBOMs, default to the one Docker uses for now.

SGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants