-
Notifications
You must be signed in to change notification settings - Fork 611
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
feat: cosign sign #556
feat: cosign sign #556
Conversation
fe088fa
to
50c15a1
Compare
@AkihiroSuda would you mind testing this in your environment, we have a macOS laptop, so, didn't test it well, we tried on CentOS by leveraging your Vagrantfile, but I just want to be sure about the development, it'd be perfect if you can test this on your own. 🙋🏻♂️ |
7caa0b7
to
c02db9c
Compare
seems there is a problem with the Go modules 👇 https://github.com/containerd/nerdctl/runs/4299324111?check_suite_focus=true#step:4:555 but couldn't make it work, I really don't understand why I'm getting this error, can you please help @AkihiroSuda, thanks in advance, but it is not a blocker thing to build binary itself which means that I can still run the following commands to build binary: GOOS=linux make binaries && \
GOOS=linux go test -c ./cmd/nerdctl |
Probably you need some |
Depending on etcd and opentelemetry seems too much heavy. Can we somehow reduce these deps? |
c02db9c
to
2ad0c24
Compare
cc: @Dentrax |
cmd/nerdctl/pull.go
Outdated
@@ -48,6 +54,7 @@ func newPullCommand() *cobra.Command { | |||
pullCommand.Flags().StringSlice("platform", nil, "Pull content for a specific platform") | |||
pullCommand.RegisterFlagCompletionFunc("platform", shellCompletePlatforms) | |||
pullCommand.Flags().Bool("all-platforms", false, "Pull content for all platforms") | |||
pullCommand.Flags().Bool("verify", false, "Verify the image with cosign") |
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.
Maybe this should be a string flag --verify=(none|cosign)
so that we can eventually add other verifier such as Notary (v2).
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.
Also, can we have integration tests?
The tests should cover both good sign and bad sign.
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.
String flag --verify=(none|cosign)
would make sense to implement! However, what about adding this feature when someone wants to work with notary to implement in nerdctl? But we can do it anyway if you want, since it's a good long-term feature!
For the integration tests, we probably need to store cosign.key
and cosign.pub
files in the ./examples
or smth folder. And we will be depended on cosign
executable (must be installed) to run all integration tests, is it OK?
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.
Notary support doesn't need to be added right now. We just have to design the CLI flag to be extensible to cover notary (or something else) in future.
For the integration tests, we probably need to store cosign.key and cosign.pub files in the ./examples or smth folder. And we will be depended on cosign executable (must be installed) to run all integration tests, is it OK?
The key should be generated during the tests by executing cosign
. (as we generate ocicrypt keys in image_encrypt_linux_test.go
)
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.
(So, maybe we should change push --cosign
to push --sign=(none|cosign)
for consistency with pull --verify=(none|cosign)
. Sorry for going back and forth.)
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.
Great, we've enhanced the flag according to your reviews
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.
I think we wrote a simple integration test that creates a cosign-key-pair and run push&pull test cases, but not sure if it is effective. We couldn't able to run the tests in Vagrant since it could not find the testutil.go
file. 🤔 What is the right way to run the all test?
cmd/nerdctl/pull.go
Outdated
cosignCmd.Env = append(cosignCmd.Env, "COSIGN_EXPERIMENTAL=true") | ||
} | ||
|
||
cosignCmd.Args = append(cosignCmd.Args, rawRef) |
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 is racy (sigstore/cosign#648), so at least we have to print a warning when rawRef
does not contain the explicit digest value.
Ideally, we should resolve the digest before shelling out cosign
(and print the validated digest).
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.
that's so true, thanks for the warning, done.
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.
The latest revision seems to have this race again
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.
Thanks, but this race has to be either resolved or warned with logrus.Warn
: https://github.com/containerd/nerdctl/pull/556/files#r759121329
Also please squash commits
2e2d337
to
db44e9e
Compare
why |
looks like it prevents passing a password by redirected stdin when |
fixed, I don't why :/ |
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com> Co-authored-by: Furkan Türkal <furkan.turkal@trendyol.com> Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
anything else do we need to fix or update? kindly ping @AkihiroSuda @fahedouch @ktock |
} | ||
return nil | ||
} | ||
|
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.
The race #556 (comment) seems introduced again in the latest revision.
imgutil.EnsureImage
should be called with the verified digest value when verifier == "cosign"
Signed-off-by: Batuhan Apaydın batuhan.apaydin@trendyol.com
Co-authored-by: Furkan Türkal furkan.turkal@trendyol.com
Fixes #423
I forgot that we can't have a digest before pushing the image, so, we have to do it right after pushing the image. 🙋🏻♂️