You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "bneradt (via GitHub)" <gi...@apache.org> on 2024/02/01 21:07:11 UTC
[PR] Fixing remap acl rules for @action=allow [trafficserver]
bneradt opened a new pull request, #11031:
URL: https://github.com/apache/trafficserver/pull/11031
If a user specifies an @action=allow remap.config ACL rule, then the implication is that requests with methods not in the allow list would be denied. Before this patch, allow ACL rules would just never deny. This fixes that behavior so that allow ACL rules that match on IP but not on method deny.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixing remap acl rules for @action=allow [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on PR #11031:
URL: https://github.com/apache/trafficserver/pull/11031#issuecomment-1928472863
[approve ci autest]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixing remap acl rules for @action=allow [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on code in PR #11031:
URL: https://github.com/apache/trafficserver/pull/11031#discussion_r1475158728
##########
src/proxy/http/remap/UrlRewrite.cc:
##########
@@ -411,43 +411,50 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, url_mapping *map)
ink_release_assert(ats_is_ip(&s->client_info.src_addr));
- s->client_connection_enabled = true; // Default is that we allow things unless some filter matches
+ s->client_connection_allowed = true; // Default is that we allow things unless some filter matches
- for (acl_filter_rule *rp = map->filter; rp; rp = rp->next) {
- bool match = true;
+ int rule_index = 0;
+ for (acl_filter_rule *rp = map->filter; rp; rp = rp->next, ++rule_index) {
+ bool method_matches = true;
if (rp->method_restriction_enabled) {
if (method_wksidx >= 0 && method_wksidx < HTTP_WKSIDX_METHODS_CNT) {
- match = rp->standard_method_lookup[method_wksidx];
+ method_matches = rp->standard_method_lookup[method_wksidx];
} else if (!rp->nonstandard_methods.empty()) {
- match = false;
+ method_matches = false;
} else {
int method_str_len;
const char *method_str = s->hdr_info.client_request.method_get(&method_str_len);
- match = rp->nonstandard_methods.count(std::string(method_str, method_str_len));
+ method_matches = rp->nonstandard_methods.count(std::string(method_str, method_str_len));
}
Review Comment:
The other changes in this patch are test, comment, or variable rename changes. This is where the functional change happens. It simply does this:
1. Distinguish between method matches (`method_matches`) and IP matches `ip_matches`).
2. If `ip_matches`, then the rule applies and `method_matches` will apply based upon whether it is a deny or allow rule.
Without this change, we don't enforce allow rules for non-matched methods. Which defeats the purpose of an allow rule.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixing remap acl rules for @action=allow [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on PR #11031:
URL: https://github.com/apache/trafficserver/pull/11031#issuecomment-1922389923
[approve ci autest]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixing remap acl rules for @action=allow [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on PR #11031:
URL: https://github.com/apache/trafficserver/pull/11031#issuecomment-1928489241
After playing with this more, this got replaced by:
https://github.com/apache/trafficserver/pull/11033
This PR is therefore no longer necessary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixing remap acl rules for @action=allow [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on code in PR #11031:
URL: https://github.com/apache/trafficserver/pull/11031#discussion_r1475158728
##########
src/proxy/http/remap/UrlRewrite.cc:
##########
@@ -411,43 +411,50 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, url_mapping *map)
ink_release_assert(ats_is_ip(&s->client_info.src_addr));
- s->client_connection_enabled = true; // Default is that we allow things unless some filter matches
+ s->client_connection_allowed = true; // Default is that we allow things unless some filter matches
- for (acl_filter_rule *rp = map->filter; rp; rp = rp->next) {
- bool match = true;
+ int rule_index = 0;
+ for (acl_filter_rule *rp = map->filter; rp; rp = rp->next, ++rule_index) {
+ bool method_matches = true;
if (rp->method_restriction_enabled) {
if (method_wksidx >= 0 && method_wksidx < HTTP_WKSIDX_METHODS_CNT) {
- match = rp->standard_method_lookup[method_wksidx];
+ method_matches = rp->standard_method_lookup[method_wksidx];
} else if (!rp->nonstandard_methods.empty()) {
- match = false;
+ method_matches = false;
} else {
int method_str_len;
const char *method_str = s->hdr_info.client_request.method_get(&method_str_len);
- match = rp->nonstandard_methods.count(std::string(method_str, method_str_len));
+ method_matches = rp->nonstandard_methods.count(std::string(method_str, method_str_len));
}
Review Comment:
The other changes in this patch are test, comment, or variable rename changes. This is where the functional change happens. It simply does this:
1. Distinguish between method matches (`method_matches`) and IP matches `ip_matches`).
2. If `ip_matches`, then the rule applies and `method_matches` will apply based upon whether it is a deny or allow rule.
Without this change, we don't enforce allow rules for non-matched methods. Which defeats the purpose of an allow rule.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fixing remap acl rules for @action=allow [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt closed pull request #11031: Fixing remap acl rules for @action=allow
URL: https://github.com/apache/trafficserver/pull/11031
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org