From 0043558082d619d0dc51ef27acda8ebb299c2f2c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 25 Feb 2016 11:48:17 +0100 Subject: publish: Do not publish nars for invalid store items. Before that, /nar requests could succeed if the requested store item exists but is invalid (although such requests were unlikely because the corresponding narinfo request would have failed.) * guix/scripts/publish.scm (render-nar): Add 'store' parameter. Use 'valid-path?' instead of 'file-exists?'. (make-request-handler): Adjust 'render-nar' call accordingly. * tests/publish.scm ("/nar/invalid"): New test. --- tests/publish.scm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/publish.scm b/tests/publish.scm index 0b92390900..6c710fe0a7 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -112,6 +112,14 @@ (define (publish-uri route) (call-with-input-string nar (cut restore-file <> temp))) (call-with-input-file temp read-string)))) +(test-equal "/nar/invalid" + 404 + (begin + (call-with-output-file (string-append (%store-prefix) "/invalid") + (lambda (port) + (display "This file is not a valid store item." port))) + (response-code (http-get (publish-uri (string-append "/nar/invalid")))))) + (test-end "publish") -- cgit v1.2.3