Skip to content

fix: validate that a method and a wildcard won't appear together #3667

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

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

EyalPazz
Copy link
Member

@EyalPazz EyalPazz commented Mar 9, 2025

What type of PR is this?
/kind bug

Which issue(s) this PR fixes:

Fixes #3647

Does this PR introduce a user-facing change?:

Doesn't allow a user to provide both an asterisk and another method/s along with it in `HTTPCORSFilter.AllowMethods`

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 9, 2025
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 9, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @EyalPazz. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@robscott robscott added this to the v1.3.0 milestone Mar 14, 2025
@robscott
Copy link
Member

Thanks @EyalPazz! There's been some good discussion about this in Slack, where there is conflicting guidance from MDN and the Fetch Living Standard, where the first suggests that this is an invalid combination and the second has been summarized well by @elizabeth-dev:

For Access-Control-Expose-Headers, Access-Control-Allow-Methods, and Access-Control-Allow-Headers response headers, the value * counts as a wildcard for requests without credentials.

with credentials being defined as:

Credentials are HTTP cookies, TLS client certificates, and authentication entries (for HTTP authentication).

Given the ambiguity here, my preference is to start with the tightest possible reasonable validation, and loosen if/when needed, since it would be very difficult (a backwards incompatible change) to tighten this validation in the future. So with all of the above context, my vote is to merge this PR. Open to other opinions.

/cc @howardjohn @youngnick @elizabeth-dev
/ok-to-test
/approve

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Mar 14, 2025
@k8s-ci-robot k8s-ci-robot requested a review from howardjohn March 14, 2025 00:45
@k8s-ci-robot
Copy link
Contributor

@robscott: GitHub didn't allow me to request PR reviews from the following users: elizabeth-dev.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

Thanks @EyalPazz! There's been some good discussion about this in Slack, where there is conflicting guidance from MDN and the Fetch Living Standard, where the first suggests that this is an invalid combination and the second has been summarized well by @elizabeth-dev:

For Access-Control-Expose-Headers, Access-Control-Allow-Methods, and Access-Control-Allow-Headers response headers, the value * counts as a wildcard for requests without credentials.

with credentials being defined as:

Credentials are HTTP cookies, TLS client certificates, and authentication entries (for HTTP authentication).

Given the ambiguity here, my preference is to start with the tightest possible reasonable validation, and loosen if/when needed, since it would be very difficult (a backwards incompatible change) to tighten this validation in the future. So with all of the above context, my vote is to merge this PR. Open to other opinions.

/cc @howardjohn @youngnick @elizabeth-dev
/ok-to-test
/approve

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 14, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: EyalPazz, robscott

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 14, 2025
@youngnick
Copy link
Contributor

Agreed that starting with the tightest validation is better here.

@elizabeth-dev
Copy link

+1 to @robscott's conclusion. I wonder if we could find people from MDN to weigh in on why their docs seem to differ from the standard.

@robscott
Copy link
Member

@EyalPazz this LGTM if you can get the tests to pass.

@youngnick
Copy link
Contributor

Looks like this just needs a make generate run.

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 18, 2025
@EyalPazz EyalPazz force-pushed the no-wildcard-and-method branch from ea20952 to 039d712 Compare March 18, 2025 07:59
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 18, 2025
@EyalPazz
Copy link
Member Author

/retest

@EyalPazz
Copy link
Member Author

The problem was with contains, it's only for strings

@EyalPazz
Copy link
Member Author

@robscott

@youngnick
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 18, 2025
@k8s-ci-robot k8s-ci-robot merged commit fa7591e into kubernetes-sigs:main Mar 18, 2025
13 checks passed
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CORS should not allow wildcard and a specific method
5 participants