git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 1/2] http: support cookie redaction when tracing

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 18, 2018, 18:25 UTC
Message-ID
<CAPig+cRyTL6LXk0JXTcotP8yco1-TxRVZxOWEu-YOnUfEhjr=g@mail.gmail.com>
In-Reply-To
<b0d7c8cbdd1c6e32f05f95ebde4612eb8bd16fdf.1516235197.git.jonathantanmy@google.com>
On Wed, Jan 17, 2018 at 7:34 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
Show 10 quoted lines
> When using GIT_TRACE_CURL, Git already redacts the "Authorization:" and
> "Proxy-Authorization:" HTTP headers. Extend this redaction to a
> user-specified list of cookies, specified through the
> "GIT_REDACT_COOKIES" environment variable.
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
>  http.c                      | 55 +++++++++++++++++++++++++++++++++++++++++++++
>  t/t5551-http-fetch-smart.sh | 12 ++++++++++
>  2 files changed, 67 insertions(+)
Please document GIT_REDACT_COOKIES in Documentation/git.txt.
Show 13 quoted lines
> diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
> @@ -364,5 +364,17 @@ test_expect_success 'custom http headers' '
> +test_expect_success 'GIT_REDACT_COOKIES redacts cookies' '
> +       rm -rf clone &&
> +       echo "Set-Cookie: NotSecret=Foo" >cookies &&
> +       echo "Set-Cookie: Secret=Bar" >>cookies &&
> +       GIT_TRACE_CURL=true GIT_REDACT_COOKIES=Secret,AnotherSecret \
> +               git -c "http.cookieFile=$(pwd)/cookies" clone \
> +               $HTTPD_URL/smart/repo.git clone 2>err &&
> +       grep "Cookie:.*NotSecret=Foo" err &&
> +       grep "Cookie:.*Secret=<redacted>" err &&
> +       ! grep "Cookie:.*Secret=Bar" err
> +'

The looseness of these grep expressions (/Cookie:.*Secret/ also matches "Cookie: NotSecret", for instance) requires extra concentration on the part of the reader to see that you do indeed cover all cases. I wonder, therefore, if it would be better to tighten them to instead match the exact string.

Also, after reading the implementation, I had expected to see testing of the "Cookie: foo=bar; cow=moo" case, as well as the handled corner cases, such as missing missing "=" and missing value after "=".

Previous: Jonathan Tan
Message 5 of 5 in “Cookie redaction during GIT_TRACE_CURL”
  1. 0/2 Cookie redaction during GIT_TRACE_CURLJonathan Tan, Jan 18, 2018
  2. 2/2 http: support omitting data from tracesJonathan Tan, Jan 18, 2018
  3. Eric SunshineJan 18, 2018
  4. 1/2 http: support cookie redaction when tracingJonathan Tan, Jan 18, 2018
  5. Eric SunshineJan 18, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.