-
Notifications
You must be signed in to change notification settings - Fork 545
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
Adding warning to pin to digest #2311
Conversation
Signed-off-by: chaosinthecrd <[email protected]>
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, but i will defer to the maintainers to have a final call
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.
Thank you!
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.
Thank you for this change 🙏
Can you add a release note to the PR description?
@@ -151,6 +151,10 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, regOpts options.Regist | |||
return fmt.Errorf("unable to resolve attachment %s for image %s", attachment, inputImg) | |||
} | |||
|
|||
if _, ok := ref.(name.Tag); ok { | |||
fmt.Println("Warning: Tag used in reference to identify the image. Consider supplying the digest for immutability.") |
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 know it's annoying, but I'm going to bikeshed the message a little bit. Appreciate your patience 🙂
Can you revise the message to something like:
WARNING: Image reference %s uses a tag, not a digest, to identify the image to sign.
This can lead you to sign a different image than the intended one. Please use a digest (
example.com/ubuntu@sha256:abcdef...
) rather than tag (example.com/ubuntu:latest
) for the input to cosign. The ability to refer to images by tag will be removed in a future release.%s: inputImg
Feel free to make modifications, but I want to hit the following points:
- "Warning" should be "WARNING" for consistency with other messages in the codebase.
- Gives motivation.
- Tells you how to fix the issue with examples.
- Mentions that digest references will be required in the future.
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.
If we print the warning after we resolve the digest, the error message can give you exactly the command to run instead, without needing a placeholder 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.
If we print the warning after we resolve the digest, the error message can give you exactly the command to run instead, without needing a placeholder digest.
I was thinking this... but by telling the user the digest they should plan to use... doesn't that hold them susceptible for the very problem that the warning tries to avoid? Instead the warning should say "make sure you figure out what the digest of the image is, but we are not the ones to tell you now, just know for next time". Maybe I have other thought it @imjasonh
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.
+1 to @ChaosInTheCRD here.
BTW I'm following up in #2313 so we can have discussion there.
@@ -151,6 +151,10 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, regOpts options.Regist | |||
return fmt.Errorf("unable to resolve attachment %s for image %s", attachment, inputImg) | |||
} | |||
|
|||
if _, ok := ref.(name.Tag); ok { | |||
fmt.Println("Warning: Tag used in reference to identify the image. Consider supplying the digest for immutability.") |
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.
Can we use fmt.Fprintln(os.Stderr, "...")
instead? We like to reserve STDOUT for the output of the command.
Oops, don't worry I'll make these changes |
Signed-off-by: chaosinthecrd [email protected]
Provides functionality mentioned in #2047