summaryrefslogtreecommitdiff
path: root/tests/substitute.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-12-13 19:45:47 +0100
committerLudovic Courtès <ludo@gnu.org>2018-12-14 00:02:59 +0100
commit60b04024f8823192b74c1ed5b14f318049865ac7 (patch)
treef7473e247c3d6f926d757b316b00216523800a86 /tests/substitute.scm
parent6b34499dc62a55283dabd04c39f9b4d53fcf13c8 (diff)
substitute: Ignore irrelevant narinfo signatures.
Fixes <https://bugs.gnu.org/33733>. Fixes a bug whereby 'guix substitute' would accept narinfos whose signature does not cover the StorePath/NarHash/References tuple. * guix/scripts/substitute.scm (narinfo-sha256)[%mandatory-fields]: New variable. Compute SIGNED-FIELDS; return #f unless each of the %MANDATORY-FIELDS is among SIGNED-FIELDS. * tests/substitute.scm ("query narinfo with signature over nothing") ("query narinfo with signature over irrelevant bits"): New tests.
Diffstat (limited to 'tests/substitute.scm')
-rw-r--r--tests/substitute.scm42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/substitute.scm b/tests/substitute.scm
index 964a57f30b7..f4f2e9512d1 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -1,6 +1,6 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org> 2;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
3;;; Copyright © 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
6;;; 6;;;
@@ -211,6 +211,46 @@ a file for NARINFO."
211 (lambda () 211 (lambda ()
212 (guix-substitute "--query")))))))) 212 (guix-substitute "--query"))))))))
213 213
214(test-equal "query narinfo with signature over nothing"
215 ;; The signature is computed over the empty string, not over the important
216 ;; parts, so the narinfo must be ignored.
217 ""
218
219 (with-narinfo (string-append "Signature: " (signature-field "") "\n"
220 %narinfo "\n")
221 (string-trim-both
222 (with-output-to-string
223 (lambda ()
224 (with-input-from-string (string-append "have " (%store-prefix)
225 "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
226 (lambda ()
227 (guix-substitute "--query"))))))))
228
229(test-equal "query narinfo with signature over irrelevant bits"
230 ;; The signature is valid but it does not cover the
231 ;; StorePath/NarHash/References tuple and is thus irrelevant; the narinfo
232 ;; must be ignored.
233 ""
234
235 (let ((prefix (string-append "StorePath: " (%store-prefix)
236 "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo
237URL: example.nar
238Compression: none\n")))
239 (with-narinfo (string-append prefix
240 "Signature: " (signature-field prefix) "
241NarHash: sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
242NarSize: 42
243References: bar baz
244Deriver: " (%store-prefix) "/foo.drv
245System: mips64el-linux\n")
246 (string-trim-both
247 (with-output-to-string
248 (lambda ()
249 (with-input-from-string (string-append "have " (%store-prefix)
250 "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
251 (lambda ()
252 (guix-substitute "--query")))))))))
253
214(test-equal "query narinfo signed with authorized key" 254(test-equal "query narinfo signed with authorized key"
215 (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") 255 (string-append (%store-prefix) "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo")
216 256