-
Notifications
You must be signed in to change notification settings - Fork 904
Add Cosign signing/verification #1701
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
Conversation
|
On macOS, this increases Skopeo’s binary size by ~10 MB (from ~28.8 to ~39.0 MB, or from ~26.7 to ~36.1 stripped). That’s rather surprising, the source code diff (even more than just additions) is a bit less than 2 MB. |
73f6862 to
abc45e9
Compare
ce87bf6 to
3946086
Compare
|
|
||
| passphrase, err := cli.ReadPassphraseFile(opts.signPassphraseFile) | ||
| if err != nil { | ||
| return err | ||
| // c/image.Copy does allow creating both simple signing and Cosign signatures simultaneously, | ||
| // with independent passphrases, but that would make the CLI probably too confusing. | ||
| // For now, use the passphrase with either, but only one of them. | ||
| if opts.signPassphraseFile != "" && opts.signByFingerprint != "" && opts.signByCosignPrivateKey != "" { | ||
| return fmt.Errorf("Only one of --sign-by and sign-by-cosign-private-key can be used with sign-passphrase-file") | ||
| } | ||
| var passphrase string | ||
| if opts.signPassphraseFile != "" { | ||
| p, err := cli.ReadPassphraseFile(opts.signPassphraseFile) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| passphrase = p | ||
| } else if opts.signByCosignPrivateKey != "" { | ||
| p, err := promptForPassphrase(opts.signByCosignPrivateKey, os.Stdin, os.Stdout) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| passphrase = p | ||
| } // opts.signByFingerprint triggers a GPG-agent passphrase prompt, possibly using a more secure channel, so we usually shouldn’t prompt ourselves if no passphrase was explicitly provided. | ||
|
|
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.
This should be moved to utils.go instead of copy&pasted.
Adding to https://github.com/containers/image/issues/1601 .
cmd/skopeo/copy.go
Outdated
| flags.BoolVar(&opts.removeSignatures, "remove-signatures", false, "Do not copy signatures from SOURCE-IMAGE") | ||
| flags.StringVar(&opts.signByFingerprint, "sign-by", "", "Sign the image using a GPG key with the specified `FINGERPRINT`") | ||
| flags.StringVar(&opts.signPassphraseFile, "sign-passphrase-file", "", "File that contains a passphrase for the --sign-by key") | ||
| flags.StringVar(&opts.signByCosignPrivateKey, "sign-by-cosign-private-key", "", "Sign the image using a Cosign private key at `PATH`") |
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.
FWIW I think it’s likely the only way to generate the key right now currently is /usr/bin/cosign. I don’t know if we should use a different file format or just add a “generate key” subcommand; either way that’s a to-do item for https://github.com/containers/image/issues/1601 .
457fe13 to
916e291
Compare
916e291 to
541b4df
Compare
| **--sign-by** _key-id_ | ||
|
|
||
| Add a signature using that key ID for an image name corresponding to _destination-image_ | ||
| Add a “simple signing” signature using that key ID for an image name corresponding to _destination-image_ | ||
|
|
||
| **--sign-by-sigstore-private-key** _path_ | ||
|
|
||
| Add a sigstore signature using a private key at _path_ for an image name corresponding to _destination-image_ | ||
|
|
||
| **--sign-passphrase-file** _path_ | ||
|
|
||
| The passphare to use when signing with the key ID from `--sign-by`. Only the first line will be read. A passphrase stored in a file is of questionable security if other users can read this file. Do not use this option if at all avoidable. | ||
| The passphare to use when signing with `--sign-by` or `--sign-by-sigstore-private-key`. Only the first line will be read. A passphrase stored in a file is of questionable security if other users can read this file. Do not use this option if at all avoidable. | ||
|
|
||
| **--sign-identity** _reference_ |
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.
@vrothberg @rhatdan PTAL.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
If a passphrase is not provided, prompt for one. Outstanding: - Should have integration tests. - The signing options shared between copy and sync should live in utils.go. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
I left systemtest unmodified, to have _something_ that exercises the compatibility path. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
541b4df to
b000ada
Compare
|
Now ready for review/merging. |
vrothberg
left a comment
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.
LGTM
@rhatdan PTAL
|
LGTM |
⚠️ Warning: This is write-only code, as in I haven’t read it after myself, it has never been run, and it has no tests yet. Might be completely broken.It really needsunit andintegration tests, and interoperability testing.Depends on UNMERGED containers/image#1598 .Intended to cover:
dir:, c/storage; and copying them aroundEnd-user visible UI surface:
registries.d/*.yamluse-cosign-attachments = truein one or more of the existing sections.--sign-by-cosign-private-keyoptions added here.type: cosignSignedinpolicy.json.dir:.