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

Adding warning to pin to digest #2311

Merged
merged 1 commit into from Oct 5, 2022

Conversation

ChaosInTheCRD
Copy link
Contributor

Signed-off-by: chaosinthecrd thomas.meadows@jetstack.io

Provides functionality mentioned in #2047

Signed-off-by: chaosinthecrd <thomas.meadows@jetstack.io>
Copy link
Member

@cpanato cpanato left a 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

Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

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

Thank you!

@priyawadhwa priyawadhwa merged commit 91b03f2 into sigstore:main Oct 5, 2022
Copy link
Contributor

@znewman01 znewman01 left a 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.")
Copy link
Contributor

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:

  1. "Warning" should be "WARNING" for consistency with other messages in the codebase.
  2. Gives motivation.
  3. Tells you how to fix the issue with examples.
  4. Mentions that digest references will be required in the future.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.")
Copy link
Contributor

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.

@znewman01
Copy link
Contributor

Oops, don't worry I'll make these changes

@github-actions github-actions bot added this to the v1.13.0 milestone Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants