git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Tan <jonathantanmy@google.com>
To: Jeff Hostetler <git@jeffhostetler.com>
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
	Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH v4 4/6] list-objects: filter objects in traverse_commit_list
Date: Thu, 16 Nov 2017 12:21:33 -0800	[thread overview]
Message-ID: <20171116122133.4cc718414579c1a5a682174b@google.com> (raw)
In-Reply-To: <20171116180743.61353-5-git@jeffhostetler.com>

On Thu, 16 Nov 2017 18:07:41 +0000
Jeff Hostetler <git@jeffhostetler.com> wrote:

> +/*
> + * Return 1 if the given string needs armoring because of "special"
> + * characters that may cause injection problems when a command passes
> + * the argument to a subordinate command (such as when upload-pack
> + * launches pack-objects).
> + *
> + * The usual alphanumeric and key punctuation do not trigger it.
> + */ 
> +static int arg_needs_armor(const char *arg)

First of all, about the injection problem, replying to your previous e-mail
[1]:

https://public-inbox.org/git/61855872-221b-0e97-abaa-24a011ad899e@jeffhostetler.com/

> I couldn't use quote.[ch] because it is more concerned with
> quoting pathnames because of LF and CR characters within
> them -- rather than semicolons and quotes and the like which
> I was concerned about.

sq_quote_buf() (or one of the other similarly-named functions) should
solve this problem, right? The single quotes around the argument takes
care of LF, CR, and semicolons, and things like backslashes and quotes
are taken care of as documented.

I don't think we need to invent another encoding to solve this.

> +{
> +	const unsigned char *p;
> +
> +	for (p = (const unsigned char *)arg; *p; p++) {
> +		if (*p >= 'a' && *p <= 'z')
> +			continue;
> +		if (*p >= 'A' && *p <= 'Z')
> +			continue;
> +		if (*p >= '0' && *p <= '9')
> +			continue;
> +		if (*p == '-' || *p == '_' || *p == '.' || *p == '/')
> +			continue;

If we do take this approach, can ':' also be included?

> +	if (skip_prefix(arg, "sparse:oid=", &v0)) {
> +		struct object_context oc;
> +		struct object_id sparse_oid;
> +
> +		/*
> +		 * Try to parse <oid-expression> into an OID for the current
> +		 * command, but DO NOT complain if we don't have the blob or
> +		 * ref locally.
> +		 */
> +		if (!get_oid_with_context(v0, GET_OID_BLOB,
> +					  &sparse_oid, &oc))
> +			filter_options->sparse_oid_value = oiddup(&sparse_oid);
> +		filter_options->choice = LOFC_SPARSE_OID;
> +		if (arg_needs_armor(v0))
> +			filter_options->requires_armor = v0 - arg;
> +		return 0;
> +	}

In your previous e-mail, you mentioned:

> yes.  I always pass filter_options.raw_value over the wire.
> The code above tries to parse it and put it in an OID for
> private use by the current process -- just like the size limit
> value in the blob:limit filter.

So I think this function should complain if you don't have the blob or
ref locally. (I envision that if a filter string is to be directly sent
to a server, it should be stored as a string, not processed by this
function first.)

  reply	other threads:[~2017-11-16 20:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 18:07 [PATCH v4 0/6] Partial clone part 1: object filtering Jeff Hostetler
2017-11-16 18:07 ` [PATCH v4 1/6] dir: allow exclusions from blob in addition to file Jeff Hostetler
2017-11-16 18:07 ` [PATCH v4 2/6] oidmap: add oidmap iterator methods Jeff Hostetler
2017-11-16 18:07 ` [PATCH v4 3/6] oidset: add iterator methods to oidset Jeff Hostetler
2017-11-16 18:07 ` [PATCH v4 4/6] list-objects: filter objects in traverse_commit_list Jeff Hostetler
2017-11-16 20:21   ` Jonathan Tan [this message]
2017-11-16 21:49     ` Jeff Hostetler
2017-11-16 21:57       ` Jeff King
2017-11-17  2:14         ` Junio C Hamano
2017-11-17 15:42           ` Jeff Hostetler
2017-11-17 22:19             ` Jeff King
2017-11-16 18:07 ` [PATCH v4 5/6] rev-list: add list-objects filtering support Jeff Hostetler
2017-11-16 20:43   ` Jonathan Tan
2017-11-17  2:14     ` Junio C Hamano
2017-11-17 17:36       ` Jeff Hostetler
2017-11-16 18:07 ` [PATCH v4 6/6] pack-objects: add list-objects filtering Jeff Hostetler

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=20171116122133.4cc718414579c1a5a682174b@google.com \
    --to=jonathantanmy@google.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --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).