-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
formatter: print request header without query string #15711
formatter: print request header without query string #15711
Conversation
Signed-off-by: Tero Saarni <[email protected]>
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Tero Saarni <[email protected]>
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply FormatterProviderPtr
doesn't work here? Sorry for nitpicking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, it did not work...
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
@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 <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
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 <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one nit, otherwise generally LGTM. My only remaining question is whether this should be included/built by default (it is right now, maybe it shouldn't be).
Over to @dio for another round. Thanks!
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
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 <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
/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 <[email protected]>
Signed-off-by: Tero Saarni [email protected]
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 followsSubstitutionFormatParser
and reusesSubstitutionFormatParser::parseCommandHeader()
for parsing the command arguments.In order to get
check_format.py
to pass, I needed to add entry toCODEOWNERS
but 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