formatter: print request header without query string#15711
formatter: print request header without query string#15711mattklein123 merged 30 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
test/extensions/formatter/req_without_query/req_without_query_test.cc
Outdated
Show resolved
Hide resolved
|
FWIW, we've achieved the equivalent of and then from the access log format string: though I do still think it'll be nice to have an extension with cc: @sc0ttbeardsley |
rgs1
left a comment
There was a problem hiding this comment.
Generally LGTM, left two comments plus let's get the build fixed and I'll make another pass.
source/extensions/formatter/req_without_query/req_without_query.cc
Outdated
Show resolved
Hide resolved
test/extensions/formatter/req_without_query/req_without_query_test.cc
Outdated
Show resolved
Hide resolved
Thanks! I did not know about this filter. In general, I have some doubts about about this PR. Adding a complete extension for the single purpose of removing I've also done some experiments with more general purpose formatter, inspired by your example with Header-To-Metadata, which allows following formatters:
- name: envoy.formatter.regex_substitute
typed_config:
"@type": type.googleapis.com/envoy.extensions.formatter.regex_substitute.v3.RegexSubstituteConfig
command_name: REQ_WITHOUT_QUERY
regex_value_rewrite:
pattern:
google_re2: {}
regex: "^(/[^?]*).*$"
substitution: "\\1"but would this then be duplication of functionality? |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
|
@tsaarni sorry I was out for a health issue. Sorry was not able to update this earlier. But generally, the PR is good. If you resolve the conflict I'll take a look at it as soon as I can. And it is nice to have that REQ_WITHOUT_QUERY shorthand. |
test/extensions/formatter/req_without_query/req_without_query_test.cc
Outdated
Show resolved
Hide resolved
| class ReqWithoutQueryCommandParser : public ::Envoy::Formatter::CommandParser { | ||
| public: | ||
| ReqWithoutQueryCommandParser() = default; | ||
| ::Envoy::Formatter::FormatterProviderPtr parse(const std::string& token, size_t, |
There was a problem hiding this comment.
Simply FormatterProviderPtr doesn't work here? Sorry for nitpicking.
There was a problem hiding this comment.
Same as above, it did not work...
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@dio No problem with delays, glad to see you back! I've now resolved the conflict. I wonder if you have opinion about #15711 (comment), that is: more general purpose formatter (regex manipulation) vs this one (dedicated for query string alone)? I'm OK with anything at the end, but just wanted to hear your thoughts :-) |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
|
Check and in another case in different target (full log here) I saw @rgs1 mentioning this in #14855 (comment) but there it was |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
|
Could I kindly ask help in reviewing of this PR? I think @dio might be still unavailable, so I was hoping maybe others could be able to help and look at this also? |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Thanks @mattklein123. I've now added entry to release notes and changed the security posture. |
|
Oops looks like it needs a main merge. /wait |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
|
There has been quite many flakes but these tests now seem to be failing quite consistently and I don't seem to get clean CI run anymore
I saw some other PRs have had same failures, so I wonder if this is a flake as well, or could it have something to do with the changes in this PR? |
|
Yeah, it's happening on master as well. |
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni tero.saarni@est.tech
Commit Message:
Adds formatter extension implementing a command operator that writes HTTP request header to access log without including the query string. Resolves #7583.
Additional Description:
Motivation for this change: Query string may contain sensitive information introducing potential vulnerability since access logs may unintentionally expose this information. If the problem cannot be fixed in the proxied application itself, the vulnerability can be mitigated by removing query string from the access logs.
This PR is similar to #7847 but implemented as extension and it is first in-tree formatter extension (xref #14512).
It implements command
%REQ_WITHOUT_QUERY(X?Y):Z%which works in the same way as existing command operator%REQ(X?Y):Z%. The proposed implementation closely followsSubstitutionFormatParserand reusesSubstitutionFormatParser::parseCommandHeader()for parsing the command arguments.In order to get
check_format.pyto pass, I needed to add entry toCODEOWNERSbut since I don't know who should be added, I added @dio and myself as a placeholder for now.Risk Level: Low
Testing: unit test
Docs Changes: New extension category added to docs
Release Notes: formatter: command operator to log request headers without query string.
Platform Specific Features: N/A