-
Notifications
You must be signed in to change notification settings - Fork 205
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
MINOR: Refine route-acl rules to prevent unintended prefix matches #692
base: master
Are you sure you want to change the base?
MINOR: Refine route-acl rules to prevent unintended prefix matches #692
Conversation
Refactors the `AddCustomRoute` function to eliminate redundancy introduced in commit c28d620. The updated code removes repetition without add extra spaces.
51c67af
to
7f273cc
Compare
Since `route-acl` annotated rules take precedence over others, this commit updates its behavior to ensure they do not unintentionally overwrite other rules that share the same prefix. For example, a rule matching the path /api should not inadvertently handle requests to /apiary.
7f273cc
to
d40fa9d
Compare
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'd like to know if there's anything I can do to facilitate the merge of this PR. I understand that using regex might have some performance impact (though I'm not sure about this). If that's a concern, we could implement two separate rules instead: # matches all paths that begin with `/api/`
use_backend app_api_http if { var(txn.host) -m str api.demo } { path -m beg /api/ } { ... }
# matches all requests with the exact path `/api`
use_backend app_api_http if { var(txn.host) -m str api.demo } { path -m str /api } { ... } This approach would achieve the same goal of preventing unintended matches (like /apiary) while potentially avoiding any regex performance overhead, if that's the case. Please let me know if there are any other concerns I can address to help move this PR forward. Regarding the failed check |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Since
route-acl
annotated rules take precedence over others, this PR updates its behavior to ensure they do not unintentionally overwrite other rules that share the same word prefix.For example, a rule matching the path prefix
/api
should not inadvertently handle requests to/apiary
.To address this, the rule
{ path -m beg /api }
has been replaced with a alternative that validates the URL's termination, ensuring it matches only/api$
or/api/.*
:For better maintainability, this PR also refactors the
AddCustomRoute
function to eliminate redundancy introduced in commit c28d620. The updated code removes repetition without add extra spaces.