moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
8.19k stars 1.16k forks source link

Get attestations separate from build output #3458

Open jedevc opened 1 year ago

jedevc commented 1 year ago

Currently, when buildkit exports attestations, it exports them inline with the rest of the content:

While this is most designed for use cases where the attestations are intended for publishing, using the results in CI/CD pipelines is more complicated. For these cases, a user will likely want to extract the attestations separately from the exported result.

For example:

Ideally, BuildKit should support generating these attestations separately from the main output, to enable these use cases. A couple of implementation possibilities:

  1. Use #2760, and create (or modify) a dedicated attestations exporter that only exports all the attestations. Using #3403, the user can then precisely configure which attestations end up where, and can create a pipeline to easily get the attestations separately. One issue with the above is that attestations vary between exporters (e.g. the subject of a local attestation is the list of all files in the export, while in an image attestation it's the digest of the platform manifest). We should be able to get the exact same attestation that is exported.
  2. Return the generated attestations in the exporter response (mostly likely not directly, but we could use the new build history api to write the attestations to the content store and then allow the client to read them using a returned descriptor).
slonopotamus commented 11 months ago

Today, I learned there is a attestation-inline=false build option. Does it solve your issue?

jedevc commented 11 months ago

Today, I learned there is a attestation-inline=false build option. Does it solve your issue?

Unfortunately not really. There's no functionality in buildkit today to do anything as described above - I wrote up some additional context in https://github.com/moby/buildkit/pull/4435#issuecomment-1830109768:

small rant (hindsight is 20/20). inline is such a weird name for this behavior, it's nothing about inline attestations, it's more about a tag that different exporters can use to detect if an attestation should be included by default.