From: Junio C Hamano <gitster@pobox.com>
To: Dave Borowitz <dborowitz@google.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required
Date: Mon, 06 Jul 2015 09:12:39 -0700 [thread overview]
Message-ID: <xmqqk2ud2rk8.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAD0k6qSJeNBX=kmo4dn-=SqHGottXT2PJfpCD=y_SKNwEMDMyA@mail.gmail.com> (Dave Borowitz's message of "Mon, 6 Jul 2015 11:22:02 -0400")
Dave Borowitz <dborowitz@google.com> writes:
> Unfortunately, optional LFs still make the stored certs for later
> auditing and parsing a bit illegible. This is one way in which push
> certs are fundamentally different from the rest of the wire protocol,
> which is not intended to be persisted.
Hmm, I am not sure I follow.
> The corner case I pointed out before where nonce runs into commands is
> not the only one.
>
> Consider the following cert fragment:
> 001fpushee git://localhost/repo
> 0029nonce 1433954361-bde756572d665bba81d8
>
> A naive cert storage/auditing implementation would store the raw
> payload that needs to be verified, without the pkt-line framing. In
> this case:
> pushee git://localhost/repononce 1433954361-bde756572d665bba81d8
"Without the pkt-line framing" is fine, but my understanding (or,
the intention of the original implementor) of this part of the
protocol is that "packets between the push-cert packet and the
push-cert-end packet carry the meat of the each line of the
certificate, one packet per line".
If pkt-line is allowed to omit the terminating LFs, then it follows
that the receiving ends can simply do something like what I
illustrated in $gmane/273196 (in java or whatever other
implementation platform they use) to collect packets between
"push-cert" and "push-cert-end", knowing that the packets may or may
not have terminating LF and supplying the omitted LFs themselves
when they receive the cert before verifying and storing.
So in order to reconstitute the "raw payload without pkt-line framing",
the omitted LF obviously needs to be added. Why is that a problem?
Side note: think of it in a different way. The key word of the
first paragraph above is "the meat of"; if your cert has two
lines
"pushee $URL<LF>nonce 1234-5670<LF>"
the lines in it are "pushee $URL<LF>" and "nonce 1234-5670<LF>"
but the meat of them are "pushee $URL" and "nonce 1234-5670".
The protocol wants to carry an array with two elements, ("pushee
$URL", "nonce 1234-5670"), as the hypothetical cert has two
lines. And then "\n".join(the cert array) . "\n" would be how
you reconstruct the original payload.
The illustration in $gmane/273196 is slightly cheating in that
sense. Instead of first creating an array of plain strings
without LF termination and joining them together later, it knows
that we will LF-join in the end, and abuses the LF in the
original payload that came from the sender and supplies its own
if the sender omitted it.
It is very similar to and in the opposite of how each ref advertisement
is handled. Until the first flush, each packet is expected to carry
the object name and the ref name. A pkt-line framing may add
terminating LF but that obviously is not part of the ref name.
> A naive parser that wants to find the pushee would look for "pushee
> <urlish>", which would be wrong in this case. (To say nothing of the
> fact that "pushee" might actually be "-0700pushee".)
>
> The alternatives for someone writing a parser are:
> a. Store the original pkt-line framing.
> b. Write a parser in some other clever way, e.g. parsing the entire
> cert in reverse might work.
>
> Neither of these is very satisfying, and both reduce human legibility
> of the stored payload.
>
>>> > If LF is optional, then with that approach you might end up with a
>>> > section of that buffer like:
>>>
>>> I think I touched on this in my previous message. You cannot send
>>> an empty line anywhere, and this is not limited to push-cert section
>>> of the protocol. Strictly speaking, the wire level allows it, but I
>>> do not think the deployed client APIs easily lets you deal with it.
>>>
>>> So you must follow the "SHOULD terminate with LF" for an empty line,
>>> even when you choose to ignore the "SHOULD" in most other places.
>>>
>>> I do not think it is such a big loss, as long as it is properly
>>> documented.
next prev parent reply other threads:[~2015-07-06 16:12 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 18:08 [PATCH 0/7] Clarify signed push protocol documentation Dave Borowitz
2015-07-01 18:08 ` [PATCH 1/7] pack-protocol.txt: Add warning about protocol inaccuracies Dave Borowitz
2015-07-01 19:39 ` Jonathan Nieder
2015-07-01 19:52 ` Junio C Hamano
2015-07-01 19:56 ` Dave Borowitz
2015-07-01 18:08 ` [PATCH 2/7] pack-protocol.txt: Mark LF in command-list as optional Dave Borowitz
2015-07-01 18:21 ` Stefan Beller
2015-07-01 18:46 ` Dave Borowitz
2015-07-01 18:08 ` [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required Dave Borowitz
2015-07-01 20:00 ` Junio C Hamano
2015-07-01 20:07 ` Dave Borowitz
2015-07-01 20:49 ` Junio C Hamano
2015-07-06 14:46 ` Dave Borowitz
2015-07-06 15:22 ` Dave Borowitz
2015-07-06 15:27 ` Dave Borowitz
2015-07-06 15:29 ` Dave Borowitz
2015-07-06 15:35 ` Dave Borowitz
2015-07-06 16:12 ` Junio C Hamano [this message]
2015-07-06 15:46 ` Shawn Pearce
2015-07-06 16:28 ` Junio C Hamano
2015-07-06 16:28 ` Junio C Hamano
2015-07-06 16:38 ` Dave Borowitz
2015-07-06 16:57 ` Junio C Hamano
2015-07-06 17:11 ` Dave Borowitz
2015-07-06 17:18 ` Dave Borowitz
2015-07-06 17:34 ` Junio C Hamano
2015-07-06 17:38 ` Dave Borowitz
2015-07-06 18:06 ` Junio C Hamano
2015-07-06 18:08 ` Dave Borowitz
2015-07-06 18:23 ` Junio C Hamano
2015-07-06 17:30 ` Junio C Hamano
2015-07-06 17:35 ` Dave Borowitz
2015-07-06 17:59 ` Junio C Hamano
2015-07-01 20:36 ` Junio C Hamano
2015-07-01 20:39 ` Junio C Hamano
2015-07-02 13:53 ` Jeff King
2015-07-03 17:45 ` Junio C Hamano
2015-07-03 18:07 ` Jeff King
2015-07-03 18:43 ` Shawn Pearce
2015-07-03 18:46 ` Jeff King
2015-07-01 18:08 ` [PATCH 4/7] pack-protocol.txt: Elaborate on pusher identity Dave Borowitz
2015-07-01 18:58 ` Junio C Hamano
2015-07-01 18:08 ` [PATCH 5/7] pack-protocol.txt: Be more precise about pusher-key relationship Dave Borowitz
2015-07-01 18:08 ` [PATCH 6/7] pack-protocol.txt: Mark pushee field as optional Dave Borowitz
2015-07-01 18:56 ` Junio C Hamano
2015-07-01 19:06 ` Dave Borowitz
2015-07-01 19:07 ` Junio C Hamano
2015-07-01 19:08 ` Junio C Hamano
2015-07-01 19:31 ` Dave Borowitz
2015-07-01 18:08 ` [PATCH 7/7] send-pack.c: Die if the nonce is empty Dave Borowitz
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk2ud2rk8.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=dborowitz@google.com \
--cc=git@vger.kernel.org \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.