Subject: [bug#53608] [PATCH 0/2] Rejecting commits unrelated to the introductory commit

From: Ludovic Courtès <[email-masked]>
Date: Mon, 14 Feb 2022 11:33:59 +0100

Hi,

Maxime Devos <[email-masked]> skribis:

> Ludovic Courtès schreef op wo 09-02-2022 om 00:02 [+0100]:
>> Howdy Maxime & Attila,
>> 
>> Did you have a chance to look into this series?
>> 
>>   https://issues.guix.gnu.org/53608
>> 
>> It’s relatively simple but I’d rather have other eyeballs looking at it.
>> 
>> TIA.  :-)
>
> The concept seems reasonable to me but I cannot tell if the
> implementation is good or bad.

OK.

I went ahead and pushed these two commits:

  ca87601dd9 git-authenticate: Ensure the target is a descendant of the introductory commit.
  87d49346f3 git: Add 'commit-descendant?'.

The actual change is this extra condition:

@@ -426,6 +428,17 @@ (define commits
           (verify-introductory-commit repository keyring
                                       start-commit signer))
 
+        ;; Make sure END-COMMIT is a descendant of START-COMMIT or of one of
+        ;; AUTHENTICATED-COMMITS, which are known to be descendants of
+        ;; START-COMMIT.
+        (unless (commit-descendant? end-commit
+                                    (cons start-commit
+                                          authenticated-commits))
+          (raise (formatted-message
+                  (G_ "commit ~a is not a descendant of introductory commit ~a")
+                  (oid->string (commit-id end-commit))
+                  (oid->string (commit-id start-commit)))))
+
         (let ((stats (call-with-progress-reporter reporter
                        (lambda (report)

I encourage everyone to take a look.

Thanks,
Ludo’.