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

Fix webhook validation bug for cert subjects #6767

Merged
merged 1 commit into from Feb 19, 2024

Conversation

lunarwhite
Copy link
Contributor

Pull Request Motivation

Fixes #6504

Changes:

  • Updated misleading error messages, and related test cases.
  • Used unified commonName variable value.

Kind

/kind bug

Release Note

When using the literalSubject on a Certificate, the webhook validation for the common name now also points to the literalSubject.

and use commonName variable value

Signed-off-by: Yuedong Wu <dwcn22@outlook.com>
@jetstack-bot jetstack-bot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Feb 19, 2024
@jetstack-bot
Copy link
Collaborator

Hi @lunarwhite. Thanks for your PR.

I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jetstack-bot jetstack-bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 19, 2024
@lunarwhite
Copy link
Contributor Author

/assign @SgtCoDFish

Thanks for your guidance. PTAL whenever you get a chance.

Not sure if this fix should be cherry-picked.

@SgtCoDFish
Copy link
Member

/ok-to-test

@jetstack-bot jetstack-bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 19, 2024
Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thank you for this! It's definitely an improvement 😁

Really appreciate your involvement here!

Comment on lines -62 to +63
if len(crt.CommonName) != 0 {
el = append(el, field.Invalid(fldPath.Child("commonName"), crt.CommonName, "When providing a `LiteralSubject` no `commonName` may be provided."))
if len(commonName) != 0 {
el = append(el, field.Invalid(fldPath.Child("commonName"), commonName, "When providing a `LiteralSubject` no `commonName` may be provided."))
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I'm not sure about this change.

This is correct today, but it's possible to imagine that we might change the var commonName = crt.CommonName line above somehow and forget to update this check. I don't think we need to change this back but I'd personally probably prefer not to make this specific change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to revert this?

Copy link
Member

Choose a reason for hiding this comment

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

Naah, we don't need to revert! If I'd thought it needed to change I wouldn't have approved 😁 It's all good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the explanation!

el = append(el, field.TooLong(fldPath.Child("commonName"), crt.CommonName, 64))
el = append(el, field.TooLong(fldPath.Child("commonName"), commonName, 64))
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 19, 2024
@jetstack-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

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

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 19, 2024
@jetstack-bot jetstack-bot merged commit d2e2e25 into cert-manager:master Feb 19, 2024
6 of 7 checks passed
@lunarwhite lunarwhite deleted the fix-msg branch February 20, 2024 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. ok-to-test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webhook validation bugs for cert subjects
3 participants