envoyproxy / envoyproxy/envoy

Cannot extract response cookie value from Set-Cookie in Header-To-Metadata Filter

Open
#22,654 7 comments 0 reactions 0 assignees View on GitHub
area/http_filter help wanted
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 22h
Merged PRs (30d)
430

Description

*Title*: *Cannot extract response cookie value from Set-Cookie in Header-To-Metadata Filter*

*Description*:
I'm trying to put one of cookie values to the log using a filter 'header_to_metadata' and '%DYNAMIC_METADATA(NAMESPACE:KEY*):Z%'
It works fine for the request part, but doesn't work for response.
Maybe the problem is the following:
As I can see from the code, when we extract request cookie value, 'parseCookieValue' function is used, which searches for the 'cookie' key. But response cookie uses 'Set-Cookie' as header key. And for it there is a 'parseSetCookieValue' function, but it is not used in the filter 'header_to_metadata'.
Is there a bug or is there any other way to extract cookie value from Set-Cookie?
Configuration snippets below:
```
- name: envoy.filters.http.header_to_metadata
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.header_to_metadata.v3.Config
request_rules:
- cookie: SESSIONID
on_header_present:
metadata_namespace: envoy.sessionid.req
key: id
response_rules:
- cookie: SESSIONID
on_header_present:
metadata_namespace: envoy.sessionid.resp
key: id
```
and
```
- name: envoy.access_loggers.file
typed_config:
"@type": "type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog"
path: /dev/stdout
log_format:
text_format_source:
inline_string: "... %DYNAMIC_METADATA(envoy.sessionid.req:id)% %DYNAMIC_METADATA(envoy.sessionid.resp:id)% ..."
```

[optional *Relevant Links*:]
>https://github.com/envoyproxy/envoy/blob/0986bb6d49fbd35e20e567aec0e7d614c9d24663/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc#L36
https://github.com/envoyproxy/envoy/blob/a06001ce26a3ebbcb4c861d4fd94fe7267a2ac07/source/common/http/utility.cc#L487-L494

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.