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

Added small hacks to work around tests disabled by #1630 #1862

Merged
merged 24 commits into from
May 10, 2023

Conversation

dmpetroff
Copy link
Contributor

@dmpetroff dmpetroff commented Apr 7, 2023

Current (27.04.2023) state of PR:
req->host aka picked_authority is selected from request data in the following priority:

  • from absoluteURI (HTTP/1.1 and earlier versions)
  • from :authority header (HTTP/2)
  • from Host header (all version)

req->host is now used for cache key calculation.

Hard-coded checks (check_authority_correctness()):

  • Host header MUST be present even when request comes in form of an absolute-URI (HTTP/1.1)
  • authority information MUST be supplied (ie non-empty) for HTTP/1.1 and HTTP/2

Frang check had been update accordingly:

  • :authority == Host (HTTP/2) or (host_from_absolute_uri == Host) (HTTP/1.1)
  • host_from_forwarded_header == picked_authority (both HTTP/1.1 and HTTP/2)

@krizhanovsky krizhanovsky marked this pull request as draft April 7, 2023 15:38
@dmpetroff dmpetroff marked this pull request as ready for review April 11, 2023 15:37
@dmpetroff dmpetroff force-pushed the dp-1630-h2-host-processing branch 2 times, most recently from bc27332 to a54930c Compare April 14, 2023 11:49
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

There are several questions and comments, which probably are good to be discussed

fw/http.c Outdated Show resolved Hide resolved
fw/http.c Outdated Show resolved Hide resolved
fw/http_match.c Outdated Show resolved Hide resolved
fw/http.c Show resolved Hide resolved
fw/http.h Outdated Show resolved Hide resolved
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

There are still things to fix and improve

fw/http.c Show resolved Hide resolved
return TFW_STR_EMPTY(&authority) || TFW_STR_EMPTY(&host)
|| tfw_strcmp(&authority, &host) == 0;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do these validations in extract_req_host():

  1. tfw_http_req_process() is already too big
  2. there is no sense to check the request version twice and spread the logic among many places (we already have the frang check)

fw/http.c Outdated Show resolved Hide resolved
fw/http_match.c Outdated Show resolved Hide resolved
fw/http.h Outdated Show resolved Hide resolved
Copy link
Contributor

@const-t const-t left a comment

Choose a reason for hiding this comment

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

Please fix using TFW_HTTP_HDR_HOST in cache.c

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

There are still couple of not addressed comments and couple of a new comments to fix.

The logic looks good for me and I'd vote to fix it in the wiki (@const-t approve is required though).

fw/http.c Outdated Show resolved Hide resolved
fw/http_limits.c Show resolved Hide resolved
fw/http.c Show resolved Hide resolved
fw/http_limits.c Outdated
Comment on lines 688 to 689
" from Host header",
&FRANG_ACC2CLI(ra)->addr, "\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

&FRANG_ACC2CLI(ra)->addr not properly aligned. Also we may do not break string argument even if it wider than 80.

fw/http_limits.c Outdated
Comment on lines 686 to 688
frang_msg("Request host from absolute URI differs"
" from Host header",
&FRANG_ACC2CLI(ra)->addr, "\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
frang_msg("Request host from absolute URI differs"
" from Host header",
&FRANG_ACC2CLI(ra)->addr, "\n");
frang_msg("Request host from absolute URI differs"
" from Host header",
&FRANG_ACC2CLI(ra)->addr, "\n");

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

Just couple of unresolved comments from the previous review.

fw/http.c Outdated Show resolved Hide resolved
@@ -1025,7 +1025,7 @@
# http_header_cnt NUM;
# http_header_chunk_cnt NUM;
# http_body_chunk_cnt NUM;
# http_host_required true|false;
# http_strict_host_checking true|false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix all the Wiki docs by

tempesta.wiki$ grep http_host_required *
HTTP-security.md:`http_host_required [true|false]`
HTTP-security.md~:`http_host_required [true|false]`
HTTP-security.md.orig:`http_host_required [true|false]`  
grep: scripts: Is a directory
grep: _static: Is a directory
grep: _templates: Is a directory
Vhost-Confusion.md:    http_host_required;
Virtual-hosts-and-locations.md:* http_host_required

Copy link
Contributor

@const-t const-t left a comment

Choose a reason for hiding this comment

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

LGTM

* HTTP/2 because it cannot have an absolute URI.
* Also this MUST be removed after #1870 is complete*/
if (test_bit(TFW_HTTP_B_ABSOLUTE_URI, req->flags)) {
TfwStr host;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add new line after host declaration.

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

Just a minor cleanup

fw/http.c Outdated Show resolved Hide resolved
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

LGTM

@dmpetroff dmpetroff merged commit 7670e87 into master May 10, 2023
@dmpetroff dmpetroff deleted the dp-1630-h2-host-processing branch May 10, 2023 16:27
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.

3 participants