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: convert url variables to colon x #109

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

bzp2010
Copy link
Contributor

@bzp2010 bzp2010 commented Jan 10, 2024

Description

Currently, the path variable in OpenAPI will be converted to *, its implementation on APISIX, which allows for arbitrary strings containing slash, which potentially doesn't fit our needs.

So this PR actually replaces variables like /order/{order_id} with /order/:order_id, which is more appropriate.

Specifically:

The original implementation:

/order/{order_id} => /order/*
/order/{order_id}/good/{good_no} => /order/*/good/*

While this does work, it will actually allow requests like this to be matched:

/order/12345/blahblah => /order/*
/order/12345/54321/good/12345 => /order/*/good/*

I.e., allowing * paths like xxx/xxx to be matched, which could change the semantics of the URL and pose a security risk.

Variables such as :xxx are not allowed to contain /, i.e., they match at most one level of the directory on the URL.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

@bzp2010 bzp2010 merged commit 567d5b8 into api7:main Jan 10, 2024
8 checks passed
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

2 participants