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

headers: consistent validation #34205

Merged
merged 8 commits into from
May 27, 2024
Merged

headers: consistent validation #34205

merged 8 commits into from
May 27, 2024

Conversation

alyssawilk
Copy link
Contributor

Risk Level: low
Testing: existing tests
Docs Changes: n/a
Release Notes: inline
[Optional Runtime guard:] yes

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #34205 was opened by alyssawilk.

see: more, trace.

Copy link

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

🐱

Caused by: #34205 was opened by alyssawilk.

see: more, trace.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk marked this pull request as ready for review May 16, 2024 19:39
@alyssawilk alyssawilk enabled auto-merge (squash) May 16, 2024 19:40
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks for improving code health!

Some drive-by comments

// Reject key if it is an invalid header string
return {};
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.consistent_header_validation")) {
if (!Http::HeaderUtility::headerValueIsValid(str)) {
Copy link
Member

Choose a reason for hiding this comment

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

The intention here is checking the header key/name . So I think we should use utility headerNameIsValid instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah good catch - I'd been going off the bug which I think referenced the wrong helper. looks like same thing with the formatter.

Copy link
Member

@tyxia tyxia May 21, 2024

Choose a reason for hiding this comment

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

Yeah, tracking the code into here , we can see formatter is also using header key/name

Http::TestRequestHeaderMapImpl header_map{{"referer", "dogs.com"}};
Protobuf::Arena arena;
HeadersWrapper<Http::RequestHeaderMap> headers(arena, &header_map);
auto header = headers[CelValue::CreateStringView("dogs.com\n")];
Copy link
Member

Choose a reason for hiding this comment

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

We probably should test a invalid header key/name in particular.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so this does exercise the test code. did you just prefer an invalid string that looks like a key? PTAL

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, i was preferring a invalid string that looks like a key. Thanks for updates.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks!

Defer to @yanavlasov for final review and merge.

Copy link
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

LGTM with a spelling fix

@@ -52,6 +52,10 @@ minor_behavior_changes:
``%UPSTREAM_REMOTE_PORT%`` and ``%UPSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%`` access log format specifiers.
This behavior can be reverted by setting the runtime guard
``envoy.reloadable_features.upstream_remote_address_use_connection`` to false.
- area: http
change: |
Changing header validation checks in the substitution format utility and CEL code to do RCF complaint header validation.
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
Changing header validation checks in the substitution format utility and CEL code to do RCF complaint header validation.
Changing header validation checks in the substitution format utility and CEL code to do RFC complaint header validation.

@yanavlasov
Copy link
Contributor

Needs fixing merge conflict.

/wait

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Contributor Author

/retest

@alyssawilk
Copy link
Contributor Author

/wait on CI

@alyssawilk
Copy link
Contributor Author

/wait on CI

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Contributor Author

/wait on CI and debug cleanup

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk merged commit a22101c into envoyproxy:main May 27, 2024
53 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

3 participants