]> git.ipfire.org Git - thirdparty/git.git/commit
trace2: redact passwords from https:// URLs by default
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 22 Nov 2023 19:18:35 +0000 (19:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Nov 2023 01:30:33 +0000 (10:30 +0900)
commitb7d49ac1ecd05669edada26b990eee677a7d3c25
tree1e585d1494af8a4056132de37fe2d17ab3a6aac0
parentabcdb978ea13010357ef2bf265f7bf0c55f96dbe
trace2: redact passwords from https:// URLs by default

It is an unsafe practice to call something like

git clone https://user:password@example.com/

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`).

The new tests added in this commit uncover leaks in `builtin/clone.c`
and `remote.c`. Therefore we need to turn off
`TEST_PASSES_SANITIZE_LEAK`. The reasons:

- We observed that `the_repository->remote_status` is not released
  properly.

- We are using `url...insteadOf` and that runs into a code path where an
  allocated URL is replaced with another URL, and the original URL is
  never released.

- `remote_states` contains plenty of `struct remote`s whose refspecs
  seem to be usually allocated by never released.

More investigation is needed here to identify the exact cause and
proper fixes for these leaks/bugs.

Co-authored-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Jeff Hostetler <jeffhostetler@github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0210-trace2-normal.sh
trace2.c