http, imap-send: stop using CURLOPT_VERBOSE
Whenever GIT_CURL_VERBOSE is set, teach Git to behave as if GIT_TRACE_CURL=1 and GIT_TRACE_CURL_NO_DATA=1 is set, instead of setting CURLOPT_VERBOSE. This is to prevent inadvertent revelation of sensitive data. In particular, GIT_CURL_VERBOSE redacts neither the "Authorization" header nor any cookies specified by GIT_REDACT_COOKIES. Unifying the tracing mechanism also has the future benefit that any improvements to the tracing mechanism will benefit both users of GIT_CURL_VERBOSE and GIT_TRACE_CURL, and we do not need to remember to implement any improvement twice. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
373e9bd66e
commit
7167a62b9e
@ -197,6 +197,18 @@ test_expect_success 'GIT_TRACE_CURL redacts auth details' '
|
||||
grep "Authorization: Basic <redacted>" trace
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_CURL_VERBOSE redacts auth details' '
|
||||
rm -rf redact-auth trace &&
|
||||
set_askpass user@host pass@host &&
|
||||
GIT_CURL_VERBOSE=1 git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth 2>trace &&
|
||||
expect_askpass both user@host &&
|
||||
|
||||
# Ensure that there is no "Basic" followed by a base64 string, but that
|
||||
# the auth details are redacted
|
||||
! grep "Authorization: Basic [0-9a-zA-Z+/]" trace &&
|
||||
grep "Authorization: Basic <redacted>" trace
|
||||
'
|
||||
|
||||
test_expect_success 'disable dumb http on server' '
|
||||
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
|
||||
config http.getanyfile false
|
||||
@ -454,6 +466,18 @@ test_expect_success 'GIT_REDACT_COOKIES redacts cookies' '
|
||||
! grep "Cookie:.*Bar=2" err
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_REDACT_COOKIES redacts cookies when GIT_CURL_VERBOSE=1' '
|
||||
rm -rf clone &&
|
||||
echo "Set-Cookie: Foo=1" >cookies &&
|
||||
echo "Set-Cookie: Bar=2" >>cookies &&
|
||||
GIT_CURL_VERBOSE=1 GIT_REDACT_COOKIES=Bar,Baz \
|
||||
git -c "http.cookieFile=$(pwd)/cookies" clone \
|
||||
$HTTPD_URL/smart/repo.git clone 2>err &&
|
||||
grep "Cookie:.*Foo=1" err &&
|
||||
grep "Cookie:.*Bar=<redacted>" err &&
|
||||
! grep "Cookie:.*Bar=2" err
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_REDACT_COOKIES handles empty values' '
|
||||
rm -rf clone &&
|
||||
echo "Set-Cookie: Foo=" >cookies &&
|
||||
|
Reference in New Issue
Block a user