All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org, sandals@crustytoothpaste.net, peff@peff.net
Subject: Re: [PATCH v2 2/3] http: make GIT_TRACE_CURL auth redaction optional
Date: Wed, 13 May 2020 12:29:48 -0700	[thread overview]
Message-ID: <xmqqpnb7tyz7.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <8c70a45b24861290b64d4487383bdfa5960332ab.1589394456.git.jonathantanmy@google.com> (Jonathan Tan's message of "Wed, 13 May 2020 12:12:47 -0700")

Jonathan Tan <jonathantanmy@google.com> writes:

> diff --git a/http.c b/http.c
> index 62aa995245..77eac95d64 100644
> --- a/http.c
> +++ b/http.c
> @@ -18,6 +18,7 @@
>  
>  static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
>  static int trace_curl_data = 1;
> +static int trace_curl_redact_authorization = 1;
>  static struct string_list cookies_to_redact = STRING_LIST_INIT_DUP;
>  #if LIBCURL_VERSION_NUM >= 0x070a08
>  long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
> @@ -642,8 +643,9 @@ static void redact_sensitive_header(struct strbuf *header)
>  {
>  	const char *sensitive_header;
>  
> -	if (skip_prefix(header->buf, "Authorization:", &sensitive_header) ||
> -	    skip_prefix(header->buf, "Proxy-Authorization:", &sensitive_header)) {
> +	if (trace_curl_redact_authorization &&
> +	    (skip_prefix(header->buf, "Authorization:", &sensitive_header) ||
> +	     skip_prefix(header->buf, "Proxy-Authorization:", &sensitive_header))) {

Nice.

>  		/* The first token is the type, which is OK to log */
>  		while (isspace(*sensitive_header))
>  			sensitive_header++;
> @@ -859,6 +861,7 @@ static int get_curl_http_version_opt(const char *version_string, long *opt)
>  static CURL *get_curl_handle(void)
>  {
>  	CURL *result = curl_easy_init();
> +	const char *redact_authorization_envvar;
>  
>  	if (!result)
>  		die("curl_easy_init failed");
> @@ -997,6 +1000,10 @@ static CURL *get_curl_handle(void)
>  	setup_curl_trace(result);
>  	if (getenv("GIT_TRACE_CURL_NO_DATA"))
>  		trace_curl_data = 0;
> +	redact_authorization_envvar = getenv("GIT_REDACT_AUTHORIZATION");
> +	if (redact_authorization_envvar &&
> +	    !strcmp(redact_authorization_envvar, "0"))
> +		trace_curl_redact_authorization = 0;

Wasn't git_env_bool() designed exactly for this kind of usage?

Thanks.

  reply	other threads:[~2020-05-13 19:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 17:43 [PATCH 0/2] Safer GIT_CURL_VERBOSE Jonathan Tan
2020-05-11 17:43 ` [PATCH 1/2] t5551: test that GIT_TRACE_CURL redacts password Jonathan Tan
2020-05-12 19:08   ` Jeff King
2020-05-11 17:43 ` [PATCH 2/2] http, imap-send: stop using CURLOPT_VERBOSE Jonathan Tan
2020-05-12 19:16   ` Jeff King
2020-05-12 19:23     ` Jonathan Tan
2020-05-12 19:27       ` Jeff King
2020-05-12 23:13   ` brian m. carlson
2020-05-13  0:10     ` Junio C Hamano
2020-05-13  4:50       ` Jeff King
2020-05-13  5:05         ` Junio C Hamano
2020-05-13  6:16     ` Daniel Stenberg
2020-05-13 14:45       ` Jeff King
2020-05-13 19:12 ` [PATCH v2 0/3] Safer GIT_CURL_VERBOSE Jonathan Tan
2020-05-13 19:12   ` [PATCH v2 1/3] t5551: test that GIT_TRACE_CURL redacts password Jonathan Tan
2020-05-13 19:12   ` [PATCH v2 2/3] http: make GIT_TRACE_CURL auth redaction optional Jonathan Tan
2020-05-13 19:29     ` Junio C Hamano [this message]
2020-05-13 19:12   ` [PATCH v2 3/3] http, imap-send: stop using CURLOPT_VERBOSE Jonathan Tan
2020-05-13 19:27   ` [PATCH v2 0/3] Safer GIT_CURL_VERBOSE Junio C Hamano
2020-05-13 19:33     ` Junio C Hamano
2020-05-15 20:47       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpnb7tyz7.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    --subject='Re: [PATCH v2 2/3] http: make GIT_TRACE_CURL auth redaction optional' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.