Subject: Re: [PATCH] archive: add archive.restrictRemote option

From: Junio C Hamano <[email-masked]>
Date: Thu, 27 Feb 2014 10:37:30 -0800

Jeff King <[email-masked]> writes:

> From: Scott J. Goldman <[email-masked]>
>
> In commit ee27ca4, we started restricting remote git-archive
> invocations to only accessing reachable commits. This
> matches what upload-pack allows, but does restrict some
> useful cases (e.g., HEAD:foo). We loosened this in 0f544ee,
> which allows `foo:bar` as long as `foo` is a ref tip.
> However, that still doesn't allow many useful things, like:
>
>   1. Commits accessible from a ref, like `foo^:bar`, which
>      is reachable
>
>   2. Arbitrary sha1s, even if they are reachable.
>
> We can do a full object-reachability check for these cases,
> but it can be quite expensive if the client has sent us the
> sha1 of a tree; we have to visit every sub-tree of every
> commit in the worst case.
>
> Let's instead give site admins an escape hatch, in case they
> prefer the more liberal behavior.  For many sites, the full
> object database is public anyway (e.g., if you allow dumb
> walker access), or the site admin may simply decide the
> security/convenience tradeoff is not worth it.
>
> This patch adds a new config option to turn off the
> restrictions added in ee27ca4. It defaults to on, meaning
> there is no change in behavior by default.
>
> Signed-off-by: Jeff King <[email-masked]>

Thanks.

Do GitHub people have general aversion against signing off (or
sending out, for that matter) their own patches, unless they were
already active here before they joined GitHub, by the way?

I like the general idea and this escape hatch would be a good thing
to have.

A few comments:

 - Seeing the word combination "restrict"+"remote" before reading
   the explanation made me think "hmph, only allow remote archive
   from certain hosts but not from others?"  We are restricting the
   objects and only on the remote usage, not restricting remotes, so
   somebody else may be able to come up with a less misleading name.

 - It might be better to call the escape hatch "allow something"
   that defaults to "false".  It is merely the issue of perception,
   but having a knob to be limiting that defaults to true gives a
   wrong impression that in an ideal world remote archive ought to
   be loose and we are artificially limiting it by default.

But these are just my "reactions"; neither is an objection to the
posted patch as-is.

> ---
>  Documentation/git-archive.txt |  7 +++++++
>  archive.c                     | 13 +++++++++++--
>  t/t5000-tar-tree.sh           |  9 +++++++++
>  3 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
> index b97aaab..486cb08 100644
> --- a/Documentation/git-archive.txt
> +++ b/Documentation/git-archive.txt
> @@ -121,6 +121,13 @@ tar.<format>.remote::
>  	user-defined formats, but true for the "tar.gz" and "tgz"
>  	formats.
>  
> +archive.restrictRemote::
> +	If true, archives can only be requested by refnames. If false,

As this does not affect local use of "git archive", "requested by
refnames" may need to be clarified further.  Perhaps "remote
archives can be requested only for published refnames" or something.

Just to help starting further discussion to pick brains of others,
this paragraph could have been like this, I would think.

    archive.serveArbitraryObjectToRemote::

        By default, remote archives can be requested only for
        published refnames (e.g. "git archive --remote=origin
        master" is OK, but "git archive --remote=origin ae9677f" is
        not), to prevent peeking into unreachable commits that have
        been pruned from the repository.  This configuration
        variable can be set to bypass this security measure.

The phrase "serve arbitrary object to remote" would reflect the
purpose of the escape hatch better, I would think, but it is not a
great short-and-sweet name.

Thanks.