From patchwork Thu Dec 28 09:40:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pukkamustard X-Patchwork-Id: 58127 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E968227BBE9; Thu, 28 Dec 2023 09:41:26 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0721227BBE2 for ; Thu, 28 Dec 2023 09:41:26 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rImt0-0007d2-W5; Thu, 28 Dec 2023 04:41:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rImsy-0007cG-Rp for guix-patches@gnu.org; Thu, 28 Dec 2023 04:41:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rImsy-00082a-DZ; Thu, 28 Dec 2023 04:41:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rImsw-0005kz-5p; Thu, 28 Dec 2023 04:41:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [PATCH v4 1/7] narinfo: Add ERIS field. Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 28 Dec 2023 09:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52555 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52555@debbugs.gnu.org Cc: pukkamustard , ludo@gnu.org, maximedevos@telenet.be, Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 52555-submit@debbugs.gnu.org id=B52555.170375643421998 (code B ref 52555); Thu, 28 Dec 2023 09:41:02 +0000 Received: (at 52555) by debbugs.gnu.org; 28 Dec 2023 09:40:34 +0000 Received: from localhost ([127.0.0.1]:38506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rImsT-0005ii-Rn for submit@debbugs.gnu.org; Thu, 28 Dec 2023 04:40:34 -0500 Received: from mout01.posteo.de ([185.67.36.65]:57653) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rImsS-0005iI-5p for 52555@debbugs.gnu.org; Thu, 28 Dec 2023 04:40:32 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 5DEC0240029 for <52555@debbugs.gnu.org>; Thu, 28 Dec 2023 10:40:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1703756427; bh=C7DasrBu7qWaF2tHB6A9GffXP4Z1A0kR60CwJnxDNe0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=SnRJsjZWTZnX+OFGY84Y2sD5Sa/2AC9vIlebn3mbp3btoGkFL/6QFEKAfGMHOr57F 5YFV7U5q1rIr81U/aVUVYY7+J/PaPIIYLODitg6MgyraMyM0UW59HEgIWEoihhO3Y2 OMXG858yL56E9Dw6gJMcz4/H28YbnZMzcDP2jCub9Xnq+CZ8MH+pT4bWyaJ9XhPxc9 wwxiKJH/9bCAk19sK82p3KDrs4tjGPUc6hd+HRBmWEIuP2MheyCzQ5i5fVRFqmzCBI Yc7s71wIEXWFNBLgLz42xXTRBvFwCgTQJjgpqjOH4y0A28MKuuMvIqQ29gj7WDZueW lWbwomaJFs03g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T13Qf40s3z6tn4; Thu, 28 Dec 2023 10:40:26 +0100 (CET) From: pukkamustard Date: Thu, 28 Dec 2023 09:40:04 +0000 Message-ID: <7c1c7108a369b608e8cebbe09c4cbfe24d032067.1703316055.git.pukkamustard@posteo.net> In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/narinfo.scm ()[eris-urn]: New field. (narinfo-maker): Handle new field. (read-narifno): Handle new field. (equivalent-narinfo?): Require ERIS field to be equal. --- guix/narinfo.scm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/guix/narinfo.scm b/guix/narinfo.scm index a149d9a901..5f5ed8be6f 100644 --- a/guix/narinfo.scm +++ b/guix/narinfo.scm @@ -45,6 +45,7 @@ (define-module (guix narinfo) narinfo-file-sizes narinfo-hash narinfo-size + narinfo-eris-urn narinfo-references narinfo-deriver narinfo-system @@ -69,7 +70,7 @@ (define-module (guix narinfo) (define-record-type (%make-narinfo path uri-base uris compressions file-sizes file-hashes - nar-hash nar-size references deriver system + nar-hash nar-size eris-urn references deriver system signature contents) narinfo? (path narinfo-path) @@ -80,6 +81,7 @@ (define-record-type (file-hashes narinfo-file-hashes) (nar-hash narinfo-hash) (nar-size narinfo-size) + (eris-urn narinfo-eris-urn) (references narinfo-references) (deriver narinfo-deriver) (system narinfo-system) @@ -136,7 +138,7 @@ (define (narinfo-maker str cache-url) "Return a narinfo constructor for narinfos originating from CACHE-URL. STR must contain the original contents of a narinfo file." (lambda (path urls compressions file-hashes file-sizes - nar-hash nar-size references deriver system + nar-hash nar-size eris-urn references deriver system signature) "Return a new object." (define len (length urls)) @@ -158,6 +160,7 @@ (define (narinfo-maker str cache-url) ((lst ...) (map string->number lst))) nar-hash (and=> nar-size string->number) + (if eris-urn (string->uri eris-urn) #f) (string-tokenize references) (match deriver ((or #f "") #f) @@ -185,7 +188,7 @@ (define* (read-narinfo port #:optional url (narinfo-maker str url) '("StorePath" "URL" "Compression" "FileHash" "FileSize" "NarHash" "NarSize" - "References" "Deriver" "System" + "ERIS" "References" "Deriver" "System" "Signature") '("URL" "Compression" "FileSize" "FileHash")))) @@ -271,7 +274,13 @@ (define (equivalent-narinfo? narinfo1 narinfo2) (narinfo-references narinfo2)) (= (narinfo-size narinfo1) - (narinfo-size narinfo2)))) + (narinfo-size narinfo2)) + + ;; When downloading substitutes with ERIS the hash is not checked. To + ;; avoid malicious substitutes we must ensure that the ERIS URN is equal. + ;; See also . + (equal? (narinfo-eris-urn narinfo1) + (narinfo-eris-urn narinfo2)))) (define %compression-methods ;; Known compression methods and a thunk to determine whether they're