git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Fabian Stelzer <fs@gigacodes.de>
Cc: git@vger.kernel.org, Han-Wen Nienhuys <hanwen@google.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	"Randall S. Becker" <rsbecker@nexbridge.com>,
	Bagas Sanjaya <bagasdotme@gmail.com>,
	Hans Jerry Illikainen <hji@dyntopia.com>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Gwyneth Morgan <gwymor@tilde.club>,
	Jonathan Tan <jonathantanmy@google.com>,
	Josh Steadmon <steadmon@google.com>
Subject: Re: [PATCH 3/6] ssh signing: verify-commit/check_signature with commit date
Date: Fri, 22 Oct 2021 19:37:03 +0200	[thread overview]
Message-ID: <211022.86ee8dj6uv.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <20211022150949.1754477-4-fs@gigacodes.de>


On Fri, Oct 22 2021, Fabian Stelzer wrote:

[Just nits]

> +	if (payload_timestamp) {
> +		strbuf_addf(&verify_time, "-Overify-time=%s",
> +			    show_date(payload_timestamp, 0, &verify_date_mode));
> +	}

No braces needed.

> @@ -482,6 +495,7 @@ static int verify_ssh_signed_buffer(struct signature_check *sigc,
>  		error(_("ssh-keygen -Y find-principals/verify is needed for ssh signature verification (available in openssh version 8.2p1+)"));
>  		goto out;
>  	}
> +
>  	if (ret || !ssh_principals_out.len) {
>  		/*
>  		 * We did not find a matching principal in the allowedSigners

Stray whitespace change.

> +int parse_signed_buffer_metadata(const char *payload, const char *signer_header,
> +				 timestamp_t *payload_timestamp,
> +				 struct strbuf *payload_signer)
> +{
> +	const char *ident_line = NULL;
> +	size_t ident_len;
> +	struct ident_split ident;
> +
> +	ident_line = find_commit_header(payload, signer_header, &ident_len);
> +	if (ident_line && ident_len) {
> +		if (!split_ident_line(&ident, ident_line, ident_len)) {
> +			if (payload_timestamp && ident.date_begin &&
> +			    ident.date_end)
> +				*payload_timestamp = parse_timestamp(
> +					ident.date_begin, NULL, 10);
> +			if (payload_signer)
> +				strbuf_add(payload_signer, ident.mail_begin,
> +					(ident.mail_end - ident.mail_begin));
> +
> +			return 0;
> +		}
> +	}
> +
> +	return 1;
> +}

This would be more readable with less nesting, i.e. instead of:

    if (x) {
        if (y) {
            [...]

Doing:

    if (!x)
        return 1;
    if (!y)
        return 1;

I.e. only if you get zero from split_ident_line() do you return 0.


  reply	other threads:[~2021-10-22 17:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 15:09 [PATCH 0/6] ssh signing: verify key lifetime Fabian Stelzer
2021-10-22 15:09 ` [PATCH 1/6] ssh signing: extend check_signature to accept payload metadata Fabian Stelzer
2021-10-23 23:13   ` Junio C Hamano
2021-10-25  8:28     ` Fabian Stelzer
2021-10-25 17:16       ` Junio C Hamano
2021-10-22 15:09 ` [PATCH 2/6] ssh signing: add key lifetime test prereqs Fabian Stelzer
2021-10-22 15:09 ` [PATCH 3/6] ssh signing: verify-commit/check_signature with commit date Fabian Stelzer
2021-10-22 17:37   ` Ævar Arnfjörð Bjarmason [this message]
2021-10-25  8:31     ` Fabian Stelzer
2021-10-22 15:09 ` [PATCH 4/6] ssh signing: git log/check_signature " Fabian Stelzer
2021-10-22 15:09 ` [PATCH 5/6] ssh signing: verify-tag/check_signature with tag date Fabian Stelzer
2021-10-22 15:09 ` [PATCH 6/6] ssh signing: fmt-merge-msg/check_signature " Fabian Stelzer
2021-10-22 18:12   ` Ævar Arnfjörð Bjarmason
2021-10-25  8:39     ` Fabian Stelzer

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=211022.86ee8dj6uv.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=fs@gigacodes.de \
    --cc=git@vger.kernel.org \
    --cc=gwymor@tilde.club \
    --cc=hanwen@google.com \
    --cc=hji@dyntopia.com \
    --cc=jonathantanmy@google.com \
    --cc=rsbecker@nexbridge.com \
    --cc=sandals@crustytoothpaste.net \
    --cc=steadmon@google.com \
    --cc=sunshine@sunshineco.com \
    /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).