Skip to content

access_log: Add %REQ_WITHOUT_QUERY()% formatter#7847

Closed
dio wants to merge 1 commit intoenvoyproxy:masterfrom
dio:fix-7583
Closed

access_log: Add %REQ_WITHOUT_QUERY()% formatter#7847
dio wants to merge 1 commit intoenvoyproxy:masterfrom
dio:fix-7583

Conversation

@dio
Copy link
Member

@dio dio commented Aug 7, 2019

Description:
This patch adds %REQ_WITHOUT_QUERY(X?Y):Z% formatter to facilitate removing query string from a request header entry value. This is an attempt to fix #7583.

Also modified the metadata else-if case to match the style with other cases.

Risk Level: Low, newly added
Testing: Added unit tests
Docs Changes: Added
Release Notes: Added
Fixes #7583

Signed-off-by: Dhi Aurrahman dio@tetrate.io

Signed-off-by: Dhi Aurrahman <dio@tetrate.io>
@dio
Copy link
Member Author

dio commented Aug 7, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: asan (failed build)

🐱

Caused by: a #7847 (comment) was created by @dio.

see: more, trace.

@dio dio assigned snowp Aug 8, 2019
``":path" : "/?ok=true"``

* ``%REQ(:PATH)%`` will log: ``/?ok=true``
* ``%REQ_WITHOUT_QUERY(:PATH)%`` will log: ``/``
Copy link
Contributor

Choose a reason for hiding this comment

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

will this ever be used with any other header? wondering if it makes more sense to go with the other suggestion in the issue with making this a top level format

Copy link
Member Author

Choose a reason for hiding this comment

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

OH, I can also see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer that's why I went ahead with this. But yeah, probably a suffix operator is better?

REQ(X?Y):<MAX_LENGTH>:<POST_PROCESSING_OPERATOR>, e.g. REQ(:PATH):2:REMOVE_QUERY, REQ(:PATH):-:REMOVE_QUERY. Need to go back to discuss this in the issue then.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as there are more than one header this makes sense for I'm fine with this. Are suffix operators something we currently support? I don't feel super strongly about either, would probably go with whichever has precedent

int command_end_position = pos + token.length();

if (absl::StartsWith(token, "REQ(")) {
const bool req_without_query = absl::StartsWith(token, "REQ_WITHOUT_QUERY(");
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm looking at this code would it make more sense to have REQ_WITHOUT_QUERY just take the header key as an input instead of a string to transform? right now it has to be used with REQ so it doesn't seem like its providing any additional flexibility

@stale
Copy link

stale bot commented Aug 20, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Aug 20, 2019
@stale
Copy link

stale bot commented Aug 27, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale stalebot believes this issue/PR has not been touched recently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

:PATH in access logs without query string

2 participants