From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH] clone/fetch: anonymize URLs in the reflog
Date: Tue, 02 Jun 2020 09:55:07 -0700 [thread overview]
Message-ID: <xmqqimg9tnkk.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200601214715.GB3309882@coredump.intra.peff.net> (Jeff King's message of "Mon, 1 Jun 2020 17:47:15 -0400")
Jeff King <peff@peff.net> writes:
> On Mon, Jun 01, 2020 at 07:20:02PM +0000, Johannes Schindelin via GitGitGadget wrote:
>
>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>>
>> Even if we strongly discourage putting credentials into the URLs passed
>> via the command-line, there _is_ support for that, and users _do_ do
>> that.
>>
>> Let's scrub them before writing them to the reflog.
>
> Good idea.
>
>> This came up in an internal audit, but we do not consider this to be a
>> big deal: the reflog is local and not really shared with anybody.
>
> Agreed.
Nice.
>> builtin/clone.c | 10 ++++++----
>> builtin/fetch.c | 9 +++++++--
>> t/t5541-http-push-smart.sh | 15 +++++++++++++++
>
> The patch itself looks very neatly done.
>
>> @@ -993,11 +993,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>>
>> path = get_repo_path(repo_name, &is_bundle);
>> if (path)
>> - repo = absolute_pathdup(repo_name);
>> + display_repo = repo = absolute_pathdup(repo_name);
>> else if (!strchr(repo_name, ':'))
>> die(_("repository '%s' does not exist"), repo_name);
>> - else
>> + else {
>> repo = repo_name;
>> + display_repo = transport_anonymize_url(repo);
>> + }
>
> Not introduced by your patch, but I had to read this a few times to make
> sure we always end up with repo and display_repo set. IMHO it would be
> easier to read as:
>
> if (this) {
> repo = ...;
> display_repo = ...;
> } else if (that) {
> repo = ...;
> display_repo = ...;
> } else {
> die(...);
> }
>
> instead of sticking the die() in the middle. Maybe just personal
> preference, though. :)
For a if/elseif cascade of few-liner blocks each, I do not think it
would matter, but if a block were larger, having the die() case at
the beginning or at the end would indeed make it easier to spot any
anomalies.
>> + # should have been scrubbed down to vanilla URL
>> + git log -g master >reflog &&
>> + grep "$HTTPD_URL" reflog &&
>> + ! grep "$HTTPD_URL_USER_PASS" reflog
>> +'
>
> And you make sure we retain the username. Nice.
next prev parent reply other threads:[~2020-06-02 16:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 19:20 [PATCH] clone/fetch: anonymize URLs in the reflog Johannes Schindelin via GitGitGadget
2020-06-01 21:47 ` Jeff King
2020-06-02 16:55 ` Junio C Hamano [this message]
2020-06-04 20:08 ` [PATCH v2] " Johannes Schindelin via GitGitGadget
2020-06-04 20:30 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqimg9tnkk.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
--cc=peff@peff.net \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).