Skip to content

http: add CDN-Loop header value parser and utilities#12894

Merged
alyssawilk merged 39 commits intoenvoyproxy:masterfrom
justin-mp:cdn-loop-parser
Sep 17, 2020
Merged

http: add CDN-Loop header value parser and utilities#12894
alyssawilk merged 39 commits intoenvoyproxy:masterfrom
justin-mp:cdn-loop-parser

Conversation

@justin-mp
Copy link
Contributor

The CDN-Loop header is defined by RFC 8586 and is a comma-separated
list of values. However, it’s not possible to separate the values by
splitting on ',' because the values may have parameters, which
themselves may contain strings, which may contain commas. Thus, we
need a real parser to extract the values.

This pull request contains a CDN-Loop header parser and a utility that
uses the parser to count how many times a particular CDN’s identifier
has been seen in the header.

The parser and the utility are the first two steps towards having a
CDN-Loop aware filter. See #8183.

Risk: Low
Testing: bazel test //test/extensions/filters/http/cdn:cdn_loop_parser_test //test/extensions/filters/http/cdn:cdn_loop_utils_test
Documentation: N/A
Release Notes: N/A

Signed-off-by: Justin Mazzola Paluska justinmp@google.com

The CDN-Loop header is defined by RFC 8586 and is a comma-separated
list of values.  However, it’s not possible to separate the values by
splitting on `','` because the values may have parameters, which
themselves may contain strings, which may contain commas.  Thus, we
need a real parser to extract the values.

This pull request contains a CDN-Loop header parser and a utility that
uses the parser to count how many times a particular CDN’s identifier
has been seen in the header.

The parser and the utility are the first two steps towards having a
CDN-Loop aware filter.  See envoyproxy#8183.

Risk: Low
Testing: bazel test //test/extensions/filters/http/cdn:cdn_loop_parser_test //test/extensions/filters/http/cdn:cdn_loop_utils_test
Documentation: N/A
Release Notes: N/A

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
This fixes the following style issues:

ERROR: From ./test/extensions/filters/http/cdn/cdn_loop_parser_test.cc
ERROR: ./test/extensions/filters/http/cdn/cdn_loop_parser_test.cc:140: Don't use designated initializers in struct initialization, they are not part of C++14
ERROR: ./test/extensions/filters/http/cdn/cdn_loop_parser_test.cc:144: Don't use designated initializers in struct initialization, they are not part of C++14
ERROR: ./test/extensions/filters/http/cdn/cdn_loop_parser_test.cc:213: Don't use designated initializers in struct initialization, they are not part of C++14
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
The fix_format tool complains:

ERROR: From ./source/extensions/filters/http/cdn/cdn_loop_parser.h
ERROR: ./source/extensions/filters/http/cdn/cdn_loop_parser.h:87: Don't use designated initializers in struct initialization, they are not part of C++14
ERROR: ./source/extensions/filters/http/cdn/cdn_loop_parser.h:114: Don't use designated initializers in struct initialization, they are not part of C++14
ERROR: ./source/extensions/filters/http/cdn/cdn_loop_parser.h:137: Don't use designated initializers in struct initialization, they are not part of C++14
ERROR: ./source/extensions/filters/http/cdn/cdn_loop_parser.h:159: Don't use designated initializers in struct initialization, they are not part of C++14
ERROR: check format failed. run 'tools/code_format/check_format.py fix'

even though this isn’t a designated initializer, just a string that
looks like one.

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
@justin-mp
Copy link
Contributor Author

@alyssawilk : I added you as a code owner in addition to @penguingao and me. Please let me know if there's a better maintainer to add as a code owner.

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.

Thanks for putting this together - I'm happy to co-own :-)

I'll let Peng do first review pass, and just note a few things in passing.

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Copy link
Contributor

@penguingao penguingao left a comment

Choose a reason for hiding this comment

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

Flushing some first round comments out - I have not looked at the test. But this change seems to deserve a fuzz test. @asraa

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

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

Parsing code would be great to add fuzzers for! It seems like you'll be able to make relatively simple fuzzers for this. Feel free to make a github issue or slack dm where we can chat about the design if you need any help! I haven't taken too close of a look on the code yet, but can do soon.

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
The filter name will get embedded into various protos, so having the
more accurate name of “cdn_loop” is better.

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
This also makes the names match other extensions, like the cache one.

Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
@justin-mp
Copy link
Contributor Author

One overall thing to look at is it's a bit below the Envoy coverage bar of 96.6 (Once per-extension coverage checks are fixedby #13030 and this won't merge.)

I increased test coverage to 100% according to that link. (You may have to shift+reload to get the newest figures.)

@justin-mp
Copy link
Contributor Author

I think I've addressed all of the comments at this point. I just merged from master to get the latest changes. Let me know if there's anything more to do!

alyssawilk
alyssawilk previously approved these changes Sep 14, 2020
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
@justin-mp
Copy link
Contributor Author

@lizan Friendly ping! Anything more you need me to do?

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.

Lizan's out and his comments are addressed, so I'm going to go ahead and merge and we can sort out any further comments in a follow-up when Lizan is back.

@alyssawilk alyssawilk merged commit 9eeba8f into envoyproxy:master Sep 17, 2020
@justin-mp justin-mp deleted the cdn-loop-parser branch September 17, 2020 20:09
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.

5 participants