http: add CDN-Loop header value parser and utilities#12894
http: add CDN-Loop header value parser and utilities#12894alyssawilk merged 39 commits intoenvoyproxy:masterfrom
Conversation
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>
79e5fc9 to
734288b
Compare
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>
|
@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. |
alyssawilk
left a comment
There was a problem hiding this comment.
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>
f9862ac to
786c47d
Compare
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
penguingao
left a comment
There was a problem hiding this comment.
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>
341d92d to
874ca27
Compare
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
asraa
left a comment
There was a problem hiding this comment.
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>
81f95ea to
2e95d94
Compare
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
I increased test coverage to 100% according to that link. (You may have to shift+reload to get the newest figures.) |
|
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! |
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
Signed-off-by: Justin Mazzola Paluska <justinmp@google.com>
|
@lizan Friendly ping! Anything more you need me to do? |
alyssawilk
left a comment
There was a problem hiding this comment.
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.
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, whichthemselves 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