forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trace2: redact passwords from https:// URLs by default
It is an unsafe practice to call something like git clone https://user:[email protected]/ This not only risks leaking the password "over the shoulder" or into the readline history of the current Unix shell, it also gets logged via Trace2 if enabled. Let's at least avoid logging such secrets via Trace2, much like we avoid logging secrets in `http.c`. Much like the code in `http.c` is guarded via `GIT_TRACE_REDACT` (defaulting to `true`), we guard the new code via `GIT_TRACE2_REDACT` (also defaulting to `true`). Signed-off-by: Johannes Schindelin <[email protected]>
- Loading branch information
Showing
2 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,4 +283,22 @@ test_expect_success 'using global config with include' ' | |
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'unsafe URLs are redacted by default' ' | ||
test_when_finished \ | ||
"rm -r trace.normal unredacted.normal clone clone2" && | ||
test_config_global \ | ||
"url.$(pwd).insteadOf" https://user:[email protected]/ && | ||
test_config_global trace2.configParams "core.*,remote.*.url" && | ||
GIT_TRACE2="$(pwd)/trace.normal" \ | ||
git clone https://user:[email protected]/ clone && | ||
! grep user:pwd trace.normal && | ||
GIT_TRACE2_REDACT=0 GIT_TRACE2="$(pwd)/unredacted.normal" \ | ||
git clone https://user:[email protected]/ clone2 && | ||
grep "start .* clone https://user:[email protected]" unredacted.normal && | ||
grep "remote.origin.url=https://user:[email protected]" unredacted.normal | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters