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

Ensure Prefix matching requires trailing slash #817

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

sjberman
Copy link
Contributor

@sjberman sjberman commented Jul 5, 2023

Problem: When using a prefix path match, a path such as /foobar would match for the prefix /foo, which should not happen. Prefixes need a "/" delimiter between path segments.

Solution: In order to allow just the prefix without a trailing slash, as well as more path segments using a slash delimiter, we now create two location blocks. One uses exact matching for the configured prefix path, and the other uses prefix matching with a trailing slash.

Testing: Conformance test now passes

Closes #796

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@sjberman sjberman requested a review from a team as a code owner July 5, 2023 21:11
@github-actions github-actions bot added the bug Something isn't working label Jul 5, 2023
Copy link
Member

@ciarams87 ciarams87 left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

internal/nginx/config/servers.go Outdated Show resolved Hide resolved
@sjberman sjberman force-pushed the bug/prefix-matching branch from df10c5c to 1e9c7aa Compare July 7, 2023 18:32
@sjberman sjberman requested review from pleshakov and ciarams87 July 7, 2023 18:35
@sjberman sjberman force-pushed the bug/prefix-matching branch from 1e9c7aa to 2775152 Compare July 10, 2023 16:30
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers_test.go Outdated Show resolved Hide resolved
internal/nginx/config/servers_test.go Outdated Show resolved Hide resolved
@sjberman sjberman force-pushed the bug/prefix-matching branch from 2775152 to 9903d57 Compare July 11, 2023 17:47
@sjberman sjberman requested a review from pleshakov July 11, 2023 17:49
@sjberman
Copy link
Contributor Author

Now that all conformance tests pass, I can remove continue-on-error if we want. That way we can actually get visibility into the tests from the PR page.

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

a few comments/suggestions based on the new code. looks good otherwise

Now that all conformance tests pass, I can remove continue-on-error if we want. That way we can actually get visibility into the tests from the PR page.

👍 ,
for tracking/auditing purposes, could we merge it in a separate commit? also, it will help to simplify reverting it in case we need to

internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/nginx/config/servers_test.go Outdated Show resolved Hide resolved
internal/nginx/config/servers_test.go Outdated Show resolved Hide resolved
sjberman added 2 commits July 11, 2023 14:38
Problem: When using a prefix path match, a path such as /foobar would match for the prefix /foo, which should not happen. Prefixes need a "/" delimiter between path segments.

Solution: In order to allow just the prefix without a trailing slash, as well as more path segments using a slash delimiter, we now create two location blocks. One uses exact matching for the configured prefix path, and the other uses prefix matching with a trailing slash.
@sjberman sjberman force-pushed the bug/prefix-matching branch from 9903d57 to e7a3213 Compare July 11, 2023 20:39
@sjberman sjberman requested a review from pleshakov July 11, 2023 20:39
Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

👍 🚀

@sjberman sjberman merged commit 9bcfef0 into nginxinc:main Jul 11, 2023
@sjberman sjberman deleted the bug/prefix-matching branch July 11, 2023 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Incorrect prefix path matching
3 participants