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

Use Sigstore staging for test recordings #1577

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ LICENSE_IGNORE=\
-ignore 'configs/*/*.yaml' \
-ignore 'node_modules/**' \
-ignore 'hack/**/charts/**' \
-ignore 'acceptance/wiremock/recordings/**' \
-ignore '.tekton/*.yaml'

LINT_TO_GITHUB_ANNOTATIONS='map(map(.)[])[][] as $$d | $$d.posn | split(":") as $$posn | "::warning file=\($$posn[0]),line=\($$posn[1]),col=\($$posn[2])::\($$d.message)"'
Expand Down
4 changes: 2 additions & 2 deletions acceptance/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ func setupTUF(ctx context.Context, vars map[string]string, environment []string)
}
vars["TUF"] = tufURL

vars["CERT_IDENTITY"] = "https://kubernetes.io/namespaces/default/serviceaccounts/default"
vars["CERT_ISSUER"] = "https://kubernetes.default.svc.cluster.local"
vars["CERT_IDENTITY"] = "[email protected]"
Copy link
Member

@zregvart zregvart May 2, 2024

Choose a reason for hiding this comment

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

Not a fan of tying this to a person's identity

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. If it is executed as a GitHub Workflow, it would tie to that workflow's identity which I believe is much nicer.

FWIW, this doesn't prevent someone else from regenerating the data that expires (TUF root). In the case where a new image is needed, for whatever reason, and someone else runs the script to do so, then it's simply a matter of updating the identity values as well.

I want the process of renewing the TUF root data dead simple since it needs to happen every 6 months. Right now, I seem to be the bottleneck for performing that process. So in a way, these changes are less tied to me 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

@lcarva & @zregvart: Would tying this to the enterprisecontractcommunity[at]gmail[dot]com identity be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would tying this to the enterprisecontractcommunity[at]gmail[dot]com identity be better?

It wouldn't make it easier to re-generate the image.

I don't really see a problem with using this identity here. It's an immutable public resource and no access is granted to that identity.

The alternative is to introduce a workflow that runs the script and creates a PR against this repo. The identity used would be the one from the workflow, something like: https:/enterprise-contract/ec-cli/.github/workflows/update-test-image.yaml@refs/heads/update-test-image

We probably want a workflow anyways as we can make it run automatically every so often. That does require a bit more of effort though.

Suggestions:

  1. Merge this PR as is and have a follow up to introduce the workflow as mentioned above.
  2. Close this PR and re-create it later while also introducing the workflow.

My preference, of course, is to go with option 1 because today that solves the immediate problem that it's really hard to refresh the expiring data and no one but myself seems to be able to do it. I'd rather not be the bottleneck here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created #1622 to do this via a workflow.

vars["CERT_ISSUER"] = "https://github.com/login/oauth"

environment = append(environment, fmt.Sprintf("TUF_ROOT=%s", tuf.Root(ctx)))

Expand Down
18 changes: 10 additions & 8 deletions acceptance/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"encoding/base64"
"encoding/hex"
"encoding/pem"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -603,14 +602,17 @@ func createAndPushKeylessImage(ctx context.Context, imageName string) (context.C
sig.Certificate = certPEM
}

if cert, ok := l.Annotations[static.ChainAnnotationKey]; ok {
if strings.Contains(cert, "-\n-") {
return errors.New("thus far we have only seen chain of length 1, fix the test to support more than one certificate in chain")
if certs, ok := l.Annotations[static.ChainAnnotationKey]; ok {
for block, rest := pem.Decode([]byte(certs)); block != nil; block, rest = pem.Decode(rest) {
if block.Type != "CERTIFICATE" {
continue
}
cert := new(strings.Builder)
if err := pem.Encode(cert, block); err != nil {
return err
}
sig.Chain = append(sig.Chain, cert.String())
}
if !strings.HasSuffix(cert, "\n") { // for whatever reason the trailing newline is missing in the annotation
cert += "\n"
}
sig.Chain = []string{cert} // TODO hmm
}

where[imageName] = sig
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:3eaf7ec07c9bee51f9b4a1d1722b7f340c31045867335ab8a0b4946df7f96bb8","size":326},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar+gzip","digest":"sha256:bd9ddc54bea929a22b334e73e026d4136e5b73f5cc29942896c72e4ece69b13d","size":34}],"annotations":{"org.opencontainers.image.base.digest":"","org.opencontainers.image.base.name":""}}
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.oci.image.config.v1+json","digest":"sha256:e76feb45a3e513d30d053440066b0d9fb2bd47999894bd38fb1fb64d72d80ce3","size":326},"layers":[{"mediaType":"application/vnd.oci.image.layer.v1.tar+gzip","digest":"sha256:bd9ddc54bea929a22b334e73e026d4136e5b73f5cc29942896c72e4ece69b13d","size":34}],"annotations":{"org.opencontainers.image.base.digest":"","org.opencontainers.image.base.name":""}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"architecture":"","created":"0001-01-01T00:00:00Z","history":[{"created":"0001-01-01T00:00:00Z"}],"os":"","rootfs":{"type":"layers","diff_ids":["sha256:77d53490dbc8f3f67c8c36a6c5e9c57d624b6ed61850247559e634651ed07864"]},"config":{}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"payloadType":"application/vnd.in-toto+json","payload":"eyJfdHlwZSI6Imh0dHBzOi8vaW4tdG90by5pby9TdGF0ZW1lbnQvdjAuMSIsInByZWRpY2F0ZVR5cGUiOiJodHRw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aGEyNTYiOiI0NmM2MmExYzhkMjAxYTg0MjczYzI2NjExZTViOGRlYjE3ZmJjODU5N2JkNzUwZWVmOWJlZWFiMTYzZmUzNzE1In19XSwicHJlZGljYXRlIjp7ImJ1aWxkZXIiOnsiaWQiOiJodHRwczovL3Rla3Rvbi5kZXYvY2hhaW5zL3YyIn0sImJ1aWxkVHlwZSI6InRla3Rvbi5kZXYvdjEvUGlwZWxpbmVSdW4iLCJpbnZvY2F0aW9uIjp7ImNvbmZpZ1NvdXJjZSI6e319LCJtZXRhZGF0YSI6eyJidWlsZFN0YXJ0ZWRPbiI6IjIwMjMtMDMtMjJUMTk6Mzg6MDFaIiwiYnVpbGRGaW5pc2hlZE9uIjoiMjAyMy0wMy0yMlQxOTo0MTowNVoiLCJjb21wbGV0ZW5lc3MiOnsicGFyYW1ldGVycyI6ZmFsc2UsImVudmlyb25tZW50IjpmYWxzZSwibWF0ZXJpYWxzIjpmYWxzZX0sInJlcHJvZHVjaWJsZSI6ZmFsc2V9fX0=","signatures":[{"keyid":"","sig":"MEYCIQDE8DNuhyR4GB/H25r4XZrpMSJGgKLryCoSvDtVcJkETQIhALZJ2xmyM1g8V4c70HEp9doDe/ymHCw7zIo+3WqfS6NM"}]}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"critical":{"identity":{"docker-reference":"registry.local:5000/sigstore/testimage"},"image":{"docker-manifest-digest":"sha256:996e60caeba5a31621dbd69fc744e2686287d10564a6510bd8ef0d902960d33c"},"type":"cosign container image signature"},"optional":null}
{"critical":{"identity":{"docker-reference":"registry.local:5000/sigstore/testimage"},"image":{"docker-manifest-digest":"sha256:46c62a1c8d201a84273c26611e5b8deb17fbc8597bd750eef9beeab163fe3715"},"type":"cosign container image signature"},"optional":null}

This file was deleted.

Loading
Loading