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

Sigstore sign #15108

Merged
merged 9 commits into from
Aug 1, 2022
Merged

Sigstore sign #15108

merged 9 commits into from
Aug 1, 2022

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Jul 28, 2022

  • Allow creating sigstore signatures via --sign-by-sigstore-private-key . Like existing --sign-by, it does not work remote (in this case because we would have to copy the private key to the server).
  • Allow passing a passphrase (which is mandatory for sigstore private keys) via --sign-passphrase-file; if it is not provided, prompt interactively.
  • Also, use that passphrase for --sign-by as well, allowing non-interactive GPG use. (But --sign-passphrase-file can only be used with one of --sign-by and --sign-by-sigstore-private-key.)

Note that unlike the existing code, podman build does not yet implement sigstore (I'm not sure why it needs to, it seems not to push images?) because Buildah does not expose the feature yet.

Also, podman image sign was not extended to support sigstore.

See individual commit messages for details.

Does this PR introduce a user-facing change?

Added the ability to create sigstore signatures in `podman push` and `podman manifest push`.
Added an option to read image signing passphrase from a file.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note labels Jul 28, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 28, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mtrmac

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 28, 2022
@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 28, 2022

Draft:

@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 29, 2022

This implements the podman push part of #7705. (Not the podman image sign part.)

@mtrmac mtrmac force-pushed the sigstore-sign branch 2 times, most recently from 0009b84 to 893e630 Compare July 29, 2022 21:58
test/e2e/push_test.go Outdated Show resolved Hide resolved
htpasswd is no longer included in docker.io/library/distribution
after 2.7.0, per distribution/distribution-library-image#107 ,
and we want to upgrade to a recent version.

At least system tests currently execute htpasswd from the OS,
so it seems that it is likely to be available.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 30, 2022

This now includes (via a merge commit) #15122, so that tests can run.

After the registry update PR is merged is merged, this can be rebased on top — or, I guess, merged as is.

@mtrmac mtrmac force-pushed the sigstore-sign branch 2 times, most recently from 3bcb3d4 to 8d21c66 Compare July 30, 2022 15:17
mtrmac added 8 commits July 30, 2022 17:23
... instead of hard-coding a copy of the value.

Notably this makes hack/podman_registry actually
support the documented -i option.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... primarily so that it can support OCI artifacts.

2.8 already seems to exist in the repo.

This requires changing WaitContainerReady to also check
stderr (ultimately because docker/distribution was
updated to a more recent sirupsen/logrus, which logs
by default to stderr instead of stdout).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... to get containers/common#1106 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
AFAICS it is not used anywhere.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... because it is documented to be ignored.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
- Allow creating sigstore signatures via --sign-by-sigstore-private-key .
  Like existing --sign-by, it does not work remote (in this case
  because we would have to copy the private key to the server).
- Allow passing a passphrase (which is mandatory for sigstore private keys)
  via --sign-passphrase-file; if it is not provided, prompt interactively.
- Also, use that passphrase for --sign-by as well, allowing non-interactive
  GPG use. (But --sign-passphrase-file can only be used with _one of_
  --sign-by and --sign-by-sigstore-private-key.)

Note that unlike the existing code, (podman build) does not yet
implement sigstore (I'm not sure why it needs to, it seems not to
push images?) because Buildah does not expose the feature yet.

Also, (podman image sign) was not extended to support sigstore.

The test for this follows existing (podman image sign) tests
and doesn't work rootless; that could be improved by exposing
a registries.d override option.

The test for push is getting large; I didn't want to
start yet another registry container, but that would be an
alternative.  In the future, Ginkgo's Ordered/BeforeAll
would allow starting a registry once and using it for two
tests.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@mtrmac
Copy link
Collaborator Author

mtrmac commented Aug 1, 2022

Ready for review, see #15108 (comment) about whether it should be merged.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

@vrothberg
Copy link
Member

Ready for review, see #15108 (comment) about whether it should be merged.

I am good to merge as is.

@rhatdan @Luap99 PTAL

@vrothberg vrothberg marked this pull request as ready for review August 1, 2022 06:29
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 1, 2022
@@ -0,0 +1,11 @@
-----BEGIN ENCRYPTED COSIGN PRIVATE KEY-----
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to commit private keys for testing? IMO keys should be automatically generated before the tests and we should not used fixed ones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The format for this is cosign-specific. Right now, to generate this, we would need to install cosign during tests.

Eventually Skopeo will be taught to generate the key pair, and/or we might accept keys in more standardized formats, but that doesn’t exist yet.

(To be explicit, this key pair was generated specifically for the tests and has no other use.)

Copy link
Member

Choose a reason for hiding this comment

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

I am fine with this, looks like we already have other private keys committed anyway.

My main concern is that we are testing this one key and not random generated keys like normal users would do.

@@ -225,7 +225,7 @@ func (p *PodmanTest) WaitContainerReady(id string, expStr string, timeout int, s
return false
}

if strings.Contains(s.OutputToString(), expStr) {
if strings.Contains(s.OutputToString(), expStr) || strings.Contains(s.ErrorToString(), expStr) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks a bit weird, why are we matching stderr for a successful case. Should it be a different commit ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Never mind I think reason for this is specified in the commit Update the registry server we test against from 2.6 to 2.8 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that’s the reason. WaitContainerReady is most commonly used for the registry, so I took this fairly lazy route.

Alternatively, we could add an option whether to check stderr to this function, or maybe a specialized “start a registry and wait until ready” helper.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@rhatdan
Copy link
Member

rhatdan commented Aug 1, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 1, 2022
@openshift-merge-robot openshift-merge-robot merged commit 82137dc into containers:main Aug 1, 2022
@mtrmac mtrmac deleted the sigstore-sign branch August 1, 2022 16:41
@mtrmac mtrmac mentioned this pull request Aug 1, 2022
@mtrmac mtrmac mentioned this pull request Aug 23, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants