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

http2: replaces nghttp2 functions with equivalents from QUICHE. #24943

Merged
merged 8 commits into from
Feb 10, 2023

Conversation

birenroy
Copy link
Contributor

@birenroy birenroy commented Jan 13, 2023

Signed-off-by: Biren Roy birenroy@google.com

Commit Message: Replaces nghttp2 functions with equivalents from QUICHE.
Additional Description: Cleanup related to #23596
Risk Level: Low
Testing: ran unit and integration tests locally
Docs Changes:
Release Notes:
Platform Specific Features:

Signed-off-by: Biren Roy <birenroy@google.com>
@birenroy
Copy link
Contributor Author

/assign @diannahu
/assign @RyanTheOptimist

diannahu
diannahu previously approved these changes Jan 13, 2023
@@ -190,17 +190,16 @@ bool HeaderUtility::schemeIsValid(const absl::string_view scheme) {
}

bool HeaderUtility::headerValueIsValid(const absl::string_view header_value) {
return nghttp2_check_header_value(reinterpret_cast<const uint8_t*>(header_value.data()),
header_value.size()) != 0;
return http2::adapter::HeaderValidator::IsValidHeaderValue(header_value,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, do we need a runtime guard for this? I would imagine it's possible that this is a behavior change in the event that QUICHE and nghttp2 do something different?

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about a runtime guard for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me see if I can write a unit test that demonstrates whether there is/is not a behavior change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With ObsTextOption::kAllow, the set of characters allowed by the oghttp2 method is exactly the same as the nghttp2 function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm. Can we write a unit test then where we loop through all the possible characters and verify we get the same output? I just want to make 100% sure that this change doesn't result in some crazy corner case behavior change which isn't protected by a runtime guard? Or alternatively, if it obvious from inspection can you point me at the two methods? (Sorry to be pedantic here!)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the offline discussion and the pointer to the test.

Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

Should we link to the GitHub issues in the PR description?

@birenroy
Copy link
Contributor Author

Should we link to the GitHub issues in the PR description?

Done, thanks.

@RyanTheOptimist
Copy link
Contributor

/wait

Signed-off-by: Biren Roy <birenroy@google.com>
@birenroy
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #24943 (comment) was created by @birenroy.

see: more, trace.

@birenroy
Copy link
Contributor Author

@RyanTheOptimist I think this is ready for another look. I verified that the behavior is unchanged with the new method.

@RyanTheOptimist
Copy link
Contributor

/assign @zuercher

@RyanTheOptimist
Copy link
Contributor

@zuercher for cross-company review.

Signed-off-by: Biren Roy <birenroy@google.com>
}

bool HeaderUtility::headerNameContainsUnderscore(const absl::string_view header_name) {
return header_name.find('_') != absl::string_view::npos;
}

bool HeaderUtility::authorityIsValid(const absl::string_view header_value) {
return nghttp2_check_authority(reinterpret_cast<const uint8_t*>(header_value.data()),
header_value.size()) != 0;
return http2::adapter::HeaderValidator::IsValidAuthority(header_value);
Copy link
Member

Choose a reason for hiding this comment

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

We've confirmed this is identical to nghttp as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the QUICHE method rejects "@", which nghttp2 allows. I think this is slightly more adherent to RFC 3986 section 3.2.2.

Copy link
Member

Choose a reason for hiding this comment

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

Because it's stricter, I think that means we should have a runtime guard for this behavior so that someone can revert it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. @birenroy can you add a guard for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@RyanTheOptimist
Copy link
Contributor

/wait

Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #24943 was synchronize by birenroy.

see: more, trace.

@wbpcode
Copy link
Member

wbpcode commented Feb 8, 2023

Please merge main and resolve the ci first, thanks.

@wbpcode
Copy link
Member

wbpcode commented Feb 8, 2023

/wait

Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
@wbpcode
Copy link
Member

wbpcode commented Feb 9, 2023

cc @zuercher could you give a review again when you have free time? Thanks.

@@ -510,7 +510,7 @@ envoy_cc_library(
srcs = ["header_utility.cc"],
hdrs = ["header_utility.h"],
external_deps = [
"nghttp2",
"quiche_http2_adapter",
Copy link
Member

Choose a reason for hiding this comment

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

I'm by no means a bazel expert, but should this continue to reference nghttp2 until the runtime flag is removed?

Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

One question about deps, but otherwise lgtm.

Signed-off-by: Biren Roy <birenroy@google.com>
@birenroy
Copy link
Contributor Author

One question about deps, but otherwise lgtm.

Done.

@birenroy
Copy link
Contributor Author

@yanavlasov @KBaichoo I think this PR is ready for merge.

@KBaichoo KBaichoo merged commit 9ddd06d into envoyproxy:main Feb 10, 2023
@birenroy birenroy deleted the replace-nghttp2-functions branch January 18, 2024 15:21
yanavlasov pushed a commit that referenced this pull request Aug 19, 2024
Envoy uses the `authorityIsValid()` to validate the authority header for
both H/1 and H/2 codecs.
Previously Envoy used the nghttp2 validator and in #24943 this was
changed to oghttp2's implementation.
The two implementations differ in the way they handle the "@" character
(nghttp2 allows it, and oghttp2 doesn't).
According to the H/2 spec, the "@" character is not allowed as part of
the authority header. However, for H/1 it is allowed as part of the
"user-info@host:port" structure of the authority header.
This PR changes the validator to be similar to the nghttp2
implemenation.
The change can be temporarily dis

In the future, when Envoy fully supports UHV (#10646), the H/1 and H/2
validation parts should be decoupled, and the oghttp2 authority
validation can be used for H/2.

---------

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
duxin40 pushed a commit to duxin40/envoy that referenced this pull request Oct 15, 2024
)

Envoy uses the `authorityIsValid()` to validate the authority header for
both H/1 and H/2 codecs.
Previously Envoy used the nghttp2 validator and in envoyproxy#24943 this was
changed to oghttp2's implementation.
The two implementations differ in the way they handle the "@" character
(nghttp2 allows it, and oghttp2 doesn't).
According to the H/2 spec, the "@" character is not allowed as part of
the authority header. However, for H/1 it is allowed as part of the
"user-info@host:port" structure of the authority header.
This PR changes the validator to be similar to the nghttp2
implemenation.
The change can be temporarily dis

In the future, when Envoy fully supports UHV (envoyproxy#10646), the H/1 and H/2
validation parts should be decoupled, and the oghttp2 authority
validation can be used for H/2.

---------

Signed-off-by: Adi Suissa-Peleg <adip@google.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
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.

6 participants