Skip to content

Commit 58e2bc4

Browse files
committed
Merge branch 'jk/http-redact-fix'
Sensitive data in the HTTP trace were supposed to be redacted, but we failed to do so in HTTP/2 requests. * jk/http-redact-fix: http: match headers case-insensitively when redacting
2 parents 976d3f0 + b66c77a commit 58e2bc4

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

http.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ static void redact_sensitive_header(struct strbuf *header)
551551
const char *sensitive_header;
552552

553553
if (trace_curl_redact &&
554-
(skip_prefix(header->buf, "Authorization:", &sensitive_header) ||
555-
skip_prefix(header->buf, "Proxy-Authorization:", &sensitive_header))) {
554+
(skip_iprefix(header->buf, "Authorization:", &sensitive_header) ||
555+
skip_iprefix(header->buf, "Proxy-Authorization:", &sensitive_header))) {
556556
/* The first token is the type, which is OK to log */
557557
while (isspace(*sensitive_header))
558558
sensitive_header++;
@@ -562,7 +562,7 @@ static void redact_sensitive_header(struct strbuf *header)
562562
strbuf_setlen(header, sensitive_header - header->buf);
563563
strbuf_addstr(header, " <redacted>");
564564
} else if (trace_curl_redact &&
565-
skip_prefix(header->buf, "Cookie:", &sensitive_header)) {
565+
skip_iprefix(header->buf, "Cookie:", &sensitive_header)) {
566566
struct strbuf redacted_header = STRBUF_INIT;
567567
const char *cookie;
568568

t/t5551-http-fetch-smart.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ test_expect_success 'GIT_TRACE_CURL redacts auth details' '
196196
197197
# Ensure that there is no "Basic" followed by a base64 string, but that
198198
# the auth details are redacted
199-
! grep "Authorization: Basic [0-9a-zA-Z+/]" trace &&
200-
grep "Authorization: Basic <redacted>" trace
199+
! grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace &&
200+
grep -i "Authorization: Basic <redacted>" trace
201201
'
202202

203203
test_expect_success 'GIT_CURL_VERBOSE redacts auth details' '
@@ -208,8 +208,8 @@ test_expect_success 'GIT_CURL_VERBOSE redacts auth details' '
208208
209209
# Ensure that there is no "Basic" followed by a base64 string, but that
210210
# the auth details are redacted
211-
! grep "Authorization: Basic [0-9a-zA-Z+/]" trace &&
212-
grep "Authorization: Basic <redacted>" trace
211+
! grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace &&
212+
grep -i "Authorization: Basic <redacted>" trace
213213
'
214214

215215
test_expect_success 'GIT_TRACE_CURL does not redact auth details if GIT_TRACE_REDACT=0' '
@@ -219,7 +219,7 @@ test_expect_success 'GIT_TRACE_CURL does not redact auth details if GIT_TRACE_RE
219219
git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth &&
220220
expect_askpass both user@host &&
221221
222-
grep "Authorization: Basic [0-9a-zA-Z+/]" trace
222+
grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace
223223
'
224224

225225
test_expect_success 'disable dumb http on server' '
@@ -474,10 +474,10 @@ test_expect_success 'cookies are redacted by default' '
474474
GIT_TRACE_CURL=true \
475475
git -c "http.cookieFile=$(pwd)/cookies" clone \
476476
$HTTPD_URL/smart/repo.git clone 2>err &&
477-
grep "Cookie:.*Foo=<redacted>" err &&
478-
grep "Cookie:.*Bar=<redacted>" err &&
479-
! grep "Cookie:.*Foo=1" err &&
480-
! grep "Cookie:.*Bar=2" err
477+
grep -i "Cookie:.*Foo=<redacted>" err &&
478+
grep -i "Cookie:.*Bar=<redacted>" err &&
479+
! grep -i "Cookie:.*Foo=1" err &&
480+
! grep -i "Cookie:.*Bar=2" err
481481
'
482482

483483
test_expect_success 'empty values of cookies are also redacted' '
@@ -486,7 +486,7 @@ test_expect_success 'empty values of cookies are also redacted' '
486486
GIT_TRACE_CURL=true \
487487
git -c "http.cookieFile=$(pwd)/cookies" clone \
488488
$HTTPD_URL/smart/repo.git clone 2>err &&
489-
grep "Cookie:.*Foo=<redacted>" err
489+
grep -i "Cookie:.*Foo=<redacted>" err
490490
'
491491

492492
test_expect_success 'GIT_TRACE_REDACT=0 disables cookie redaction' '
@@ -496,8 +496,8 @@ test_expect_success 'GIT_TRACE_REDACT=0 disables cookie redaction' '
496496
GIT_TRACE_REDACT=0 GIT_TRACE_CURL=true \
497497
git -c "http.cookieFile=$(pwd)/cookies" clone \
498498
$HTTPD_URL/smart/repo.git clone 2>err &&
499-
grep "Cookie:.*Foo=1" err &&
500-
grep "Cookie:.*Bar=2" err
499+
grep -i "Cookie:.*Foo=1" err &&
500+
grep -i "Cookie:.*Bar=2" err
501501
'
502502

503503
test_expect_success 'GIT_TRACE_CURL_NO_DATA prevents data from being traced' '

0 commit comments

Comments
 (0)