Skip to content

Commit 9be8916

Browse files
committed
signed push: add "pushee" header to push certificate
Record the URL of the intended recipient for a push (after anonymizing it if it has authentication material) on a new "pushee URL" header. Because the networking configuration (SSH-tunnels, proxies, etc.) on the pushing user's side varies, the receiving repository may not know the single canonical URL all the pushing users would refer it as (besides, many sites allow pushing over ssh://host/path and https://host/path protocols to the same repository but with different local part of the path). So this value may not be reliably used for replay-attack prevention purposes, but this will still serve as a human readable hint to identify the repository the certificate refers to. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4adf569 commit 9be8916

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

Documentation/technical/pack-protocol.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ references.
484484
push-cert = PKT-LINE("push-cert" NUL capability-list LF)
485485
PKT-LINE("certificate version 0.1" LF)
486486
PKT-LINE("pusher" SP ident LF)
487+
PKT-LINE("pushee" SP url LF)
487488
PKT-LINE(LF)
488489
*PKT-LINE(command LF)
489490
*PKT-LINE(gpg-signature-lines LF)
@@ -527,6 +528,11 @@ Currently, the following header fields are defined:
527528
Identify the GPG key in "Human Readable Name <email@address>"
528529
format.
529530

531+
`pushee` url::
532+
The repository URL (anonymized, if the URL contains
533+
authentication material) the user who ran `git push`
534+
intended to push into.
535+
530536
The GPG signature lines are a detached signature for the contents
531537
recorded in the push certificate before the signature block begins.
532538
The detached signature is used to certify that the commands were

send-pack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ static int generate_push_cert(struct strbuf *req_buf,
240240
datestamp(stamp, sizeof(stamp));
241241
strbuf_addf(&cert, "certificate version 0.1\n");
242242
strbuf_addf(&cert, "pusher %s %s\n", signing_key, stamp);
243+
if (args->url && *args->url) {
244+
char *anon_url = transport_anonymize_url(args->url);
245+
strbuf_addf(&cert, "pushee %s\n", anon_url);
246+
free(anon_url);
247+
}
243248
strbuf_addstr(&cert, "\n");
244249

245250
for (ref = remote_refs; ref; ref = ref->next) {

send-pack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define SEND_PACK_H
33

44
struct send_pack_args {
5+
const char *url;
56
unsigned verbose:1,
67
quiet:1,
78
porcelain:1,

transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
827827
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
828828
args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
829829
args.push_cert = !!(flags & TRANSPORT_PUSH_CERT);
830+
args.url = transport->url;
830831

831832
ret = send_pack(&args, data->fd, data->conn, remote_refs,
832833
&data->extra_have);

0 commit comments

Comments
 (0)