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

http: remove getAll() header map API and switch all usages to get() #13363

Merged
merged 12 commits into from
Oct 12, 2020

Conversation

mattklein123
Copy link
Member

This is a follow up to 2c60632.
This forces all callers to think about multiple header values. There may be places that we want
to support multiple values, but none of them are security critical and this change should be
functionally equivalent to what exists today.

Risk Level: Low
Testing: Existing tests
Docs Changes: N/A
Release Notes: N/A

This forces all callers to think about multiple header values.

Signed-off-by: Matt Klein <[email protected]>
@mattklein123
Copy link
Member Author

@alyssawilk lmk if you want a comment for every converted prod code site. I think I had that in setec at some point and can bring it back.

@alyssawilk
Copy link
Contributor

yeah, I think any point we're automatically pulling [0] we should comment why that's OK.

@mattklein123
Copy link
Member Author

OK I will update.

@mattklein123
Copy link
Member Author

@alyssawilk updated

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for the comments.
Sending some comments back your way, mostly optional but a few I think worth cleaning up for clarity

source/common/http/header_utility.cc Outdated Show resolved Hide resolved
source/common/router/config_impl.cc Outdated Show resolved Hide resolved
source/common/router/reset_header_parser.cc Show resolved Hide resolved
source/common/router/scoped_config_impl.cc Outdated Show resolved Hide resolved
source/common/upstream/original_dst_cluster.cc Outdated Show resolved Hide resolved
source/extensions/filters/common/fault/fault_config.cc Outdated Show resolved Hide resolved
@@ -200,7 +200,7 @@ void Filter::onComplete(Filters::Common::ExtAuthz::ResponsePtr&& response) {
// Currently it is not possible to add {{"append": "1"}, {"append": "2"}} (the intended
// combined headers: {{"original": "true"}, {"append": "1"}, {"append": "2"}}) to the request
// to upstream server by only sets `headers_to_append`.
if (header_to_modify != nullptr) {
if (!header_to_modify.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In general I wonder if it's worth a docs comment somewhere that header to append appends to first value.
If had a tracing header in a non-envoy server which did multi-value,
Trace: ServerA
Trace: ServerB
I think Envoy as server C would generally end up
Trace: ServerA, ServerC
Trace: ServerB.
We offer no header order guarantees so really anyone who cares about order is ideally doing inline appends anyway, so optional.

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly I find this code mind boggingly confusing every time I look at this, between gRPC/HTTP/etc. @dio do you mind taking a look and seeing if we can improve the docs here for extauth about this behavior?

@mattklein123
Copy link
Member Author

Once we agree on this PR I'm going to need to update envoy-filter-example to get this to pass FYI.

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy[\w/]*/(v1alpha\d?|v1|v2alpha\d?|v2))|(api/envoy/type/(matcher/)?\w+.proto).
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #13363 was synchronize by mattklein123.

see: more, trace.

@mattklein123
Copy link
Member Author

@alyssawilk I think I covered most of the comments. PTAL. When you are satisfied I will fix envoy-filter-example and we can merge in lockstep.

mattklein123 added a commit to envoyproxy/envoy-filter-example that referenced this pull request Oct 9, 2020
@mattklein123
Copy link
Member Author

See envoyproxy/envoy-filter-example#135 for required filter example fix.

alyssawilk
alyssawilk previously approved these changes Oct 12, 2020
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Awesome! I'm going to let you merge this and the filter example at your convenience :-)

@alyssawilk
Copy link
Contributor

Hm, looks like CI needs a pass and it needs a merge though. I'll do another pass once you have that sorted.

mattklein123 added a commit to envoyproxy/envoy-filter-example that referenced this pull request Oct 12, 2020
alyssawilk
alyssawilk previously approved these changes Oct 12, 2020
Signed-off-by: Matt Klein <[email protected]>
Comment on lines +708 to +709
// TODO(kyessenov, PiotrSikora): This needs to either return a concatenated list of values, or
// the ABI needs to be changed to return multiple values. This is a potential security issue.
Copy link
Member Author

Choose a reason for hiding this comment

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

@kyessenov @PiotrSikora this needs to be fixed ASAP

Copy link
Member Author

Choose a reason for hiding this comment

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

(Talked to @kyessenov offline about this and it will be fixed soon)

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, the ABI in proxy-wasm/spec#1 already returns multiple values.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perfect. Let's do that then.

@mattklein123
Copy link
Member Author

@alyssawilk I need another approve if you have a sec.

@mattklein123 mattklein123 merged commit 4d77fc8 into master Oct 12, 2020
@mattklein123 mattklein123 deleted the headers_get_all branch October 12, 2020 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants