-
Notifications
You must be signed in to change notification settings - Fork 21
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 OCI Attestor #441
base: main
Are you sure you want to change the base?
New OCI Attestor #441
Conversation
metadata Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
attestation/git/git.go
Outdated
@@ -17,6 +17,7 @@ package git | |||
import ( | |||
"crypto" | |||
"fmt" | |||
giturl "github.com/whilp/git-urls" |
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.
Lets just bring this code in tree
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.
seems reasonable to me.
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.
ah shoot sorry - this code is not meant for this PR, hold on
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
…tness into oci-attestor-docker-buildx
What this PR does / why we need it
Description
The OCI attestor is currently able to tell us the Image ID and the Manifest Digest. If we are able to get the manifest for a container image , we can get its ID and use that as a backref. However in some scenarios (like in the case of multiarch images), or if we want to find where a particular container image is running based off of its Image ID, the Image ID is not too much help. Instead it would be great if we could use the OCI image digest.
Currently, the OCI attestor is not able to ascertain Image Digest. This is due to the fact that said digest is only established once it is pushed to the registry. However, many container build tools (
docker
,podman
,buildah
,ko
) provide the ability to build and push at the same time. Therefore, we can leverage this in order to allow the OCI attestor to get the OCI image digest once it is pushed.Without any known reliable way of getting the image digest of the most recently pushed container image from the container runtime, this means that the container build tool must have a mechanism for storing information about the build to a file.
Docker
offers a--metadata-file
flag that saves a metadata file of the following schema:As you can see, the container image digest is present, along with other valuable information like id of the
buildx
builder (if used), the materials used (e.g., base-image) and the name of the image (given by the user for the build. Given the support of this flag, and given thatdocker
is likely the most common container build tool, the changes in this PR primarily look for this metadata file as a product in order to populate the attestor.One behaviour that is important to note with
docker
that will affect the output of the attestor is that cross-platform builds result in less metadata. You can see this here with a metadata file output from the commandwitness run --log-level debug --step image-build -o image-build.json -a oci --signer-file-key-path=./private_key.pem -- docker buildx build . --platform linux/amd64,linux/arm64 --metadata-file=metadata.file -t ghcr.io/chaosinthecrd/mic-test:testtest --push
:In this case, the materials are not present, meaning that we cannot reliable determine the base image in this case.
Of course there are also scenarios where other build tools will be used. Some build tools (e.g.,
podman
) provide the ability to store the image digest to a file. For example, the command./witness run --log-level debug --step image-build -o image-build.json -a oci --signer-file-key-path=./private_key.pem -- /bin/sh -c "podman build . -t ghcr.io/chaosinthecrd/mic-test:testtest && podman push ghcr.io/chaosinthecrd/mic-test:testtest --digestfile=./mictest.sha256"
saves the following tomictest.sha256
:The changes in this PR support picking up products with a
sha256:
inside in this very manner. This also provides an easy mechanism for other build tools to add compatibility with the attestor in the future. Finally, it even leaves the door open for users to store the hash to a file in their pipelines in order to attest the creation of new container images.